Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-07-01 06:13:30
Exec Total Coverage
Lines: 8574 12304 69.7%
Functions: 74 107 69.2%
Branches: 5489 10195 53.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #include <stdio.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "font.h"
36 #include "zc/zc_custom.h"
37 #include "sfx.h"
38 #include "md5.h"
39 #include "zc/ffscript.h"
40 #include "particles.h"
41 #include "dialog/alert.h"
42
43 #ifdef __EMSCRIPTEN__
44 #include "base/emscripten_utils.h"
45 #endif
46
47 //FFScript FFCore;
48 extern FFScript FFCore;
49 extern ZModule zcm;
50 extern zcmodule moduledata;
51 extern uint8_t __isZQuest;
52 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
53 extern particle_list particles;
54 extern void setZScriptVersion(int32_t s_version);
55 //FFSCript FFEngine;
56
57 int32_t temp_ffscript_version = 0;
58 static bool read_ext_zinfo = false, read_zinfo = false;
59 static bool loadquest_report = false;
60 static char const* loading_qst_name = NULL;
61 static byte loading_qst_num = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 // extern bool debug;
79 extern int32_t hero_animation_speed; //lower is faster animation
80 extern std::vector<mapscr> TheMaps;
81 extern zcmap *ZCMaps;
82 extern MsgStr *MsgStrings;
83 extern DoorComboSet *DoorComboSets;
84 extern dmap *DMaps;
85 extern std::vector<newcombo> combobuf;
86 extern byte *colordata;
87 //extern byte *tilebuf;
88 extern tiledata *newtilebuf;
89 extern byte *trashbuf;
90 extern itemdata *itemsbuf;
91 extern wpndata *wpnsbuf;
92 extern comboclass *combo_class_buf;
93 extern guydata *guysbuf;
94 extern ZCHEATS zcheats;
95 extern zinitdata zinit;
96 extern char palnames[MAXLEVELS][17];
97 extern int32_t memrequested;
98 extern char *byte_conversion(int32_t number, int32_t format);
99 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
100 38 string zScript;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
38 std::map<int32_t, script_slot_data > ffcmap;
102 38 std::map<int32_t, script_slot_data > globalmap;
103 38 std::map<int32_t, script_slot_data > genericmap;
104 38 std::map<int32_t, script_slot_data > itemmap;
105 38 std::map<int32_t, script_slot_data > npcmap;
106 38 std::map<int32_t, script_slot_data > ewpnmap;
107 38 std::map<int32_t, script_slot_data > lwpnmap;
108 38 std::map<int32_t, script_slot_data > playermap;
109 38 std::map<int32_t, script_slot_data > dmapmap;
110 38 std::map<int32_t, script_slot_data > screenmap;
111 38 std::map<int32_t, script_slot_data > itemspritemap;
112 38 std::map<int32_t, script_slot_data > comboscriptmap;
113 void free_newtilebuf();
114 bool combosread=false;
115 bool mapsread=false;
116 bool fixffcs=false;
117 bool fixpolsvoice=false;
118
119
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
120
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
121
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
122
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
123
124 char qstdat_string[2048] = { 0 };
125
126 static zinfo* load_tmp_zi = NULL;
127
128 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
129 const byte clavio[9]={97,109,111,110,103,117,115,0};
130
131 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
132 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
133
134 extern combo_alias combo_aliases[MAXCOMBOALIASES];
135 extern combo_pool combo_pools[MAXCOMBOPOOLS];
136 const char *qst_error[] =
137 {
138 "OK","File not found","Invalid quest file",
139 "Version not supported","Obsolete version",
140 "Missing new data" , /* but let it pass in ZQuest */
141 "Internal error occurred", "Invalid password",
142 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
143 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
144 };
145
146 //for legacy quests -DD
147 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
148 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
149 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
150 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
151 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
152 };
153
154 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
155
156
157 void delete_combo_aliases()
158 {
159 for(int32_t j(0); j<256; j++)
160 {
161 if(combo_aliases[j].combos != NULL)
162 {
163 delete[] combo_aliases[j].combos;
164 combo_aliases[j].combos=NULL;
165 }
166
167 if(combo_aliases[j].csets != NULL)
168 {
169 delete[] combo_aliases[j].csets;
170 combo_aliases[j].csets=NULL;
171 }
172 }
173
174 }
175
176 char *byte_conversion(int32_t number, int32_t format)
177 {
178 static char num_str[40];
179
180 if(format==-1) //auto
181 {
182 format=1; //bytes
183
184 if(number>1024)
185 {
186 format=2; //kilobytes
187 }
188
189 if(number>1024*1024)
190 {
191 format=3; //megabytes
192 }
193
194 if(number>1024*1024*1024)
195 {
196 format=4; //gigabytes (dude, what are you doing?)
197 }
198 }
199
200 switch(format)
201 {
202 case 1: //bytes
203 sprintf(num_str,"%db",number);
204 break;
205
206 case 2: //kilobytes
207 sprintf(num_str,"%.2fk",float(number)/1024);
208 break;
209
210 case 3: //megabytes
211 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
212 break;
213
214 case 4: //gigabytes
215 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
216 break;
217
218 default:
219 abort();
220 break;
221 }
222
223 return num_str;
224 }
225
226 532 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
227 {
228 static char num_str1[40];
229 static char num_str2[40];
230 static char num_str[80];
231
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(format1==-1) //auto
233 {
234 532 format1=1; //bytes
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(number1>1024)
237 {
238 532 format1=2; //kilobytes
239 532 }
240
241
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 152 times.
532 if(number1>1024*1024)
242 {
243 152 format1=3; //megabytes
244 152 }
245
246
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(number1>1024*1024*1024)
247 {
248 format1=4; //gigabytes (dude, what are you doing?)
249 }
250 532 }
251
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(format2==-1) //auto
253 {
254 532 format2=1; //bytes
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(number2>1024)
257 {
258 532 format2=2; //kilobytes
259 532 }
260
261
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 494 times.
532 if(number2>1024*1024)
262 {
263 494 format2=3; //megabytes
264 494 }
265
266
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(number2>1024*1024*1024)
267 {
268 format2=4; //gigabytes (dude, what are you doing?)
269 }
270 532 }
271
272
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 152 times.
✗ Branch 4 not taken.
532 switch(format1)
273 {
274 case 1: //bytes
275 sprintf(num_str1,"%db",number1);
276 break;
277
278 case 2: //kilobytes
279 380 sprintf(num_str1,"%.2fk",float(number1)/1024);
280 380 break;
281
282 case 3: //megabytes
283 152 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
284 152 break;
285
286 case 4: //gigabytes
287 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
288 break;
289
290 default:
291 abort();
292 break;
293 }
294
295
2/5
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
✗ Branch 4 not taken.
532 switch(format2)
296 {
297 case 1: //bytes
298 sprintf(num_str2,"%db",number2);
299 break;
300
301 case 2: //kilobytes
302 38 sprintf(num_str2,"%.2fk",float(number2)/1024);
303 38 break;
304
305 case 3: //megabytes
306 494 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
307 494 break;
308
309 case 4: //gigabytes
310 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
311 break;
312
313 default:
314 abort();
315 break;
316 }
317
318 532 sprintf(num_str, "%s/%s", num_str1, num_str2);
319 532 return num_str;
320 }
321
322 char *ordinal(int32_t num)
323 {
324 static const char *ending[4] = {"st","nd","rd","th"};
325 static char ord_str[8];
326
327 char *end;
328 int32_t t=(num%100)/10;
329 int32_t n=num%10;
330
331 if(n>=1 && n<4 && t!=1)
332 end = (char *)ending[n-1];
333 else
334 end = (char *)ending[3];
335
336 sprintf(ord_str,"%d%s",num%10000,end);
337 return ord_str;
338 }
339
340 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
341 {
342 int32_t ret;
343 *version=0;
344 *build=0;
345 byte temp_map_count=map_count;
346 byte temp_midi_flags[MIDIFLAGS_SIZE];
347 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
348
349 zquestheader tempheader;
350
351 if(!f)
352 {
353 return qe_invalid;
354 }
355
356 ret=readheader(f, &tempheader, true);
357
358 if(ret)
359 {
360 return ret;
361 }
362
363 map_count=temp_map_count;
364 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
365 *version=tempheader.zelda_version;
366 *build=tempheader.build;
367 return 0;
368 }
369
370
371 bool find_section(PACKFILE *f, int32_t section_id_requested)
372 {
373
374 if(!f)
375 {
376 return false;
377 }
378
379 int32_t section_id_read;
380 bool catchup=false;
381 word dummy;
382 byte tempbyte;
383 char tempbuf[65536];
384
385
386 switch(section_id_requested)
387 {
388 case ID_RULES:
389 case ID_STRINGS:
390 case ID_MISC:
391 case ID_TILES:
392 case ID_COMBOS:
393 case ID_CSETS:
394 case ID_MAPS:
395 case ID_DMAPS:
396 case ID_DOORS:
397 case ID_ITEMS:
398 case ID_WEAPONS:
399 case ID_COLORS:
400 case ID_ICONS:
401 case ID_INITDATA:
402 case ID_GUYS:
403 case ID_MIDIS:
404 case ID_CHEATS:
405 break;
406
407 default:
408 al_trace("Bad section requested!\n");
409 return false;
410 break;
411 }
412
413 dword section_size;
414
415 //section id
416 if(!p_mgetl(&section_id_read,f,true))
417 {
418 return false;
419 }
420
421 while(!pack_feof(f))
422 {
423 switch(section_id_read)
424 {
425 case ID_RULES:
426 case ID_STRINGS:
427 case ID_MISC:
428 case ID_TILES:
429 case ID_COMBOS:
430 case ID_CSETS:
431 case ID_MAPS:
432 case ID_DMAPS:
433 case ID_DOORS:
434 case ID_ITEMS:
435 case ID_WEAPONS:
436 case ID_COLORS:
437 case ID_ICONS:
438 case ID_INITDATA:
439 case ID_GUYS:
440 case ID_MIDIS:
441 case ID_CHEATS:
442 catchup=false;
443 break;
444
445 default:
446 break;
447 }
448
449
450 while(catchup)
451 {
452 //section id
453 section_id_read=(section_id_read<<8);
454
455 if(!p_getc(&tempbyte,f,true))
456 {
457 return false;
458 }
459
460 section_id_read+=tempbyte;
461 }
462
463 if(section_id_read==section_id_requested)
464 {
465 return true;
466 }
467 else
468 {
469 //section version info
470 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 if(!p_igetw(&dummy,f,true))
476 {
477 return false;
478 }
479
480 //section size
481 if(!p_igetl(&section_size,f,true))
482 {
483 return false;
484 }
485
486 //pack_fseek(f, section_size);
487 while(section_size>65535)
488 {
489 pfread(tempbuf,65535,f,true);
490 tempbuf[65535]=0;
491 section_size-=65535;
492 }
493
494 if(section_size>0)
495 {
496 pfread(tempbuf,section_size,f,true);
497 tempbuf[section_size]=0;
498 }
499 }
500
501 //section id
502 if(!p_mgetl(&section_id_read,f,true))
503 {
504 return false;
505 }
506 }
507
508 return false;
509 }
510
511
512
513
514
515 bool valid_zqt(PACKFILE *f)
516 {
517
518 //word tiles_used;
519 //word combos_used;
520 //open the file
521 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
522 if(!f)
523 return false;
524
525 //for now, everything else is valid
526 return true;
527
528 /*int16_t version;
529 byte build;
530
531 //read the version and make sure it worked
532 if(!p_igetw(&version,f,true))
533 {
534 goto error;
535 }
536
537 //read the build and make sure it worked
538 if(!p_getc(&build,f,true))
539 goto error;
540
541 //read the tile info and make sure it worked
542 if(!p_igetw(&tiles_used,f,true))
543 {
544 goto error;
545 }
546
547 for (int32_t i=0; i<tiles_used; i++)
548 {
549 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
550 {
551 goto error;
552 }
553 }
554
555 //read the combo info and make sure it worked
556 if(!p_igetw(&combos_used,f,true))
557 {
558 goto error;
559 }
560 for (int32_t i=0; i<combos_used; i++)
561 {
562 if(!pfread(trashbuf,sizeof(newcombo),f,true))
563 {
564 goto error;
565 }
566 }
567
568 //read the palette info and make sure it worked
569 for (int32_t i=0; i<48; i++)
570 {
571 if(!pfread(trashbuf,newpdTOTAL,f,true))
572 {
573 goto error;
574 }
575 }
576 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
577 {
578 goto error;
579 }
580 for (int32_t i=0; i<MAXLEVELS; i++)
581 {
582 if(!pfread(trashbuf,PALNAMESIZE,f,true))
583 {
584 goto error;
585 }
586 }
587
588 //read the sprite info and make sure it worked
589 for (int32_t i=0; i<MAXITEMS; i++)
590 {
591 if(!pfread(trashbuf,sizeof(itemdata),f,true))
592 {
593 goto error;
594 }
595 }
596
597 for (int32_t i=0; i<MAXWPNS; i++)
598 {
599 if(!pfread(trashbuf,sizeof(wpndata),f,true))
600 {
601 goto error;
602 }
603 }
604
605 //read the triforce pieces info and make sure it worked
606 for (int32_t i=0; i<8; ++i)
607 {
608 if(!p_getc(&trashbuf,f,true))
609 {
610 goto error;
611 }
612 }
613
614
615
616 //read the game icons info and make sure it worked
617 for (int32_t i=0; i<4; ++i)
618 {
619 if(!p_igetw(&trashbuf,f,true))
620 {
621 goto error;
622 }
623 }
624
625 //read the misc colors info and map styles info and make sure it worked
626 if(!pfread(trashbuf,sizeof(zcolors),f,true))
627 {
628 goto error;
629 }
630
631 //read the template screens and make sure it worked
632 byte num_maps;
633 if(!p_getc(&num_maps,f,true))
634 {
635 goto error;
636 }
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f,true))
640 {
641 goto error;
642 }
643 }
644 if (num_maps>1) //dungeon templates
645 {
646 for (int32_t i=0; i<TEMPLATES; i++)
647 {
648 if(!pfread(trashbuf,sizeof(mapscr),f,true))
649 {
650 goto error;
651 }
652 }
653 }
654
655 //yay! it worked! close the file and say everything was ok.
656 pack_fclose(f);
657 return true;
658
659 error:
660 pack_fclose(f);
661 return false;*/
662 }
663
664 bool valid_zqt(const char *filename)
665 {
666 PACKFILE *f=NULL;
667 bool isvalid;
668 int32_t error;
669 f=open_quest_file(&error, filename, false);
670
671 if(!f)
672 {
673 // setPackfilePassword(NULL);
674 return false;
675 }
676
677 isvalid=valid_zqt(f);
678
679 clear_quest_tmpfile();
680 pack_fclose(f);
681
682 // setPackfilePassword(NULL);
683 return isvalid;
684 }
685
686 38 static std::string tmp_file_name;
687 228 void clear_quest_tmpfile()
688 {
689
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(tmp_file_name.size())
690 {
691 if(exists(tmp_file_name.c_str()))
692 delete_file(tmp_file_name.c_str());
693 tmp_file_name.clear();
694 }
695 228 }
696 /*
697 .qst file history
698
699 .qst files have always been compressed using allegro's packfiles.
700
701 At some point, an encoding layer was added. The two layers look like this:
702
703 1) The top layer is from us. See decode_file_007.
704 [0-24] Preamble "Zelda Classic Quest File"
705 [25-28] Initial decoding seed value.
706 [29-X] Allegro-encoded payload (AKA "packed" file)
707 [last 4] Checksum
708
709 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
710 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
711 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
712 The oldest quests skip the password part.
713
714 Simply, the job of this function is to peel away the top layer.
715
716 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
717 in opening and saving files. There is no version field, so they decryption key is
718 found via trial-by-error (very slow!)
719
720 There are other file types of interest:
721 - .zqt: quest template files, skips top-layer encryption pass
722 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
723 - .qu?: same as above. automated backup files
724 - .qb?: same as above. automated backup files
725 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
726
727 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
728 files are now "slh!.AG ZC Enhanced Quest File".
729 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
730 */
731 114 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
732 {
733
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (show_progress)
734 {
735 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
736 }
737
738 #ifdef __EMSCRIPTEN__
739 if (em_is_lazy_file(filename))
740 {
741 em_fetch_file(filename);
742 }
743 #endif
744 114 clear_quest_tmpfile();
745 // Note: although this is primarily for loading .qst files, it can also handle all of the
746 // file types mentioned in the comment above. No need to be told if the file being loaded
747 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
748 114 bool top_layer_compressed = false;
749 114 bool compressed = false;
750 114 bool encrypted = false;
751
752 // Input files may or may not include a top layer, which may or may not be compressed.
753 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
754 // with an allegro packfile password (longtan).
755 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
756 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
757 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
758
759 114 bool id_came_from_compressed_file = false;
760 114 const char* packfile_password = "";
761 char id[32];
762 114 id[0] = id[31] = '\0';
763 114 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
764
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (!pf)
765 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
766
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (pf)
767 {
768 111 id_came_from_compressed_file = true;
769
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (!pack_fread(id, sizeof(id)-1, pf))
770 {
771 pack_fclose(pf);
772 Z_message("Unable to read header string\n");
773 return nullptr;
774 }
775 111 pack_fclose(pf);
776 111 }
777 else
778 {
779 3 FILE* f = fopen(filename, "rb");
780
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
781 {
782 *open_error=qe_notfound;
783 return nullptr;
784 }
785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
786 {
787 fclose(f);
788 Z_message("Unable to read header string\n");
789 return nullptr;
790 }
791 3 fclose(f);
792 }
793
794
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
114 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
795 {
796 // The given file is already just the bottom layer - nothing more to do.
797 // There's no way to rewind a packfile, so just open it again.
798
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (id_came_from_compressed_file)
799 {
800 111 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
801 }
802 else
803 {
804 return pack_fopen_password(filename, F_READ, "");
805 }
806 }
807
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
808 {
809 3 top_layer_compressed = id_came_from_compressed_file;
810 3 compressed = true;
811 3 encrypted = true;
812 3 }
813 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
814 {
815 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
816 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
817
818 char tmpfilename[L_tmpnam];
819 std::tmpnam(tmpfilename);
820 FILE* tf = fopen(tmpfilename, "wb");
821 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
822
823 int c;
824 while ((c = pack_getc(pf)) != EOF)
825 {
826 fputc(c, tf);
827 }
828 fclose(tf);
829 pack_fclose(pf);
830
831 tmp_file_name = tmpfilename; //store so it can be cleaned up later
832
833 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
834 // We should put qsu in the dat file, or use a separate .qst file for new qst.
835 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
836 }
837 else
838 {
839 // Unexpected, this is going to fail some header check later.
840 }
841
842 // Everything below here is legacy code - recently saved quest files will have
843 // returned by now.
844
845 char tmpfilename[L_tmpnam];
846 3 temp_name(tmpfilename);
847 char percent_done[30];
848 3 int32_t current_method=0;
849
850 PACKFILE *f;
851 3 const char *passwd= encrypted ? datapwd : "";
852
853 // oldquest flag is set when an unencrypted qst file is suspected.
854 3 bool oldquest = false;
855 int32_t ret;
856
857
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
858 {
859 3 box_out(filename);
860 3 }
861 else
862 {
863 box_out("new quest"); // Or whatever
864 }
865 3 box_out("...");
866 3 box_eol();
867 3 box_eol();
868
869
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
870 {
871 3 box_out("Decrypting...");
872 3 box_save_x();
873 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
874
875
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
876 {
877 switch(ret)
878 {
879 case 1:
880 box_out("error.");
881 box_eol();
882 box_end(true);
883 *open_error=qe_notfound;
884 return NULL;
885
886 case 2:
887 box_out("error.");
888 box_eol();
889 box_end(true);
890 *open_error=qe_internal;
891 return NULL;
892 // be sure not to delete tmpfilename now...
893 }
894
895 if(ret==5) //old encryption?
896 {
897 current_method++;
898 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
899 box_out(percent_done);
900 box_load_x();
901 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
902 }
903
904 if(ret==5) //old encryption?
905 {
906 current_method++;
907 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
908 box_out(percent_done);
909 box_load_x();
910 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
911 }
912
913 if(ret==5) //old encryption?
914 {
915 current_method++;
916 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
917 box_out(percent_done);
918 box_load_x();
919 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
920 }
921
922 if(ret==5) //old encryption?
923 {
924 current_method++;
925 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
926 box_out(percent_done);
927 box_load_x();
928 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
929 }
930
931 if(ret)
932 {
933 oldquest = true;
934 passwd="";
935 }
936 }
937
938 3 box_out("okay.");
939 3 box_eol();
940 3 }
941 else
942 {
943 oldquest = true;
944 }
945
946 3 box_out("Opening...");
947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
949 {
950 if((compressed==1)&&(errno==EDOM))
951 {
952 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
953 }
954
955 if(!f)
956 {
957 if(!oldquest)
958 {
959 delete_file(tmpfilename);
960 }
961 box_out("error.");
962 box_eol();
963 box_end(true);
964 *open_error=qe_invalid;
965 return NULL;
966 }
967 }
968
969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
970 {
971 3 delete_file(tmpfilename);
972 3 }
973
974 3 box_out("okay.");
975 3 box_eol();
976
977 3 return f;
978 114 }
979
980 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
981 {
982 char *filename;
983 PACKFILE *f=NULL;
984 int32_t open_error=0;
985
986 strcpy(qstdat_string, "modules/classic/default.qst");
987 if(Header->templatepath[0]==0)
988 {
989 filename=(char *)malloc(2048);
990 strcpy(filename, qstdat_string);
991 }
992 else
993 {
994 // TODO: should be safe to remove this, no one seems to use custom quest templates.
995 filename=Header->templatepath;
996 }
997
998 f=open_quest_file(&open_error, filename, false);
999
1000 if(Header->templatepath[0]==0)
1001 {
1002 free(filename);
1003 }
1004
1005 if(!f)
1006 {
1007 return NULL;
1008 }
1009
1010 if(validate)
1011 {
1012 if(!valid_zqt(f))
1013 {
1014 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1015 pack_fclose(f);
1016 clear_quest_tmpfile();
1017 return NULL;
1018 }
1019 }
1020
1021 return f;
1022 }
1023
1024 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1025 {
1026 // We absolutely do not support loading from a template file to initialize data outside the editor.
1027 // TODO: move this code into zq/
1028 if (get_app_id() != App::zquest) return false;
1029
1030 combosread=false;
1031 mapsread=false;
1032 fixffcs=false;
1033
1034 switch(section_id)
1035 {
1036 case ID_RULES:
1037 case ID_STRINGS:
1038 case ID_MISC:
1039 case ID_TILES:
1040 case ID_COMBOS:
1041 case ID_CSETS:
1042 case ID_MAPS:
1043 case ID_DMAPS:
1044 case ID_DOORS:
1045 case ID_ITEMS:
1046 case ID_WEAPONS:
1047 case ID_COLORS:
1048 case ID_ICONS:
1049 case ID_INITDATA:
1050 case ID_GUYS:
1051 case ID_MIDIS:
1052 case ID_CHEATS:
1053 case ID_ITEMDROPSETS:
1054 case ID_FAVORITES:
1055 break;
1056
1057 default:
1058 return false;
1059 break;
1060 }
1061
1062 int32_t ret;
1063 word version, build;
1064 PACKFILE *f=NULL;
1065
1066 char deletefilename[1024];
1067 deletefilename[0]=0;
1068
1069 //why is this here?
1070 /*
1071 if(colordata==NULL)
1072 return false;
1073 */
1074
1075 //setPackfilePassword(datapwd);
1076 f=open_quest_template(Header, deletefilename, validate);
1077
1078 if(!f) //no file, nothing to delete
1079 {
1080 // setPackfilePassword(NULL);
1081 return false;
1082 }
1083
1084 ret=get_version_and_build(f, &version, &build);
1085
1086 if(ret||(version==0))
1087 {
1088 pack_fclose(f);
1089 clear_quest_tmpfile();
1090
1091 if(deletefilename[0])
1092 {
1093 delete_file(deletefilename);
1094 }
1095
1096 // setPackfilePassword(NULL);
1097 return false;
1098 }
1099
1100 if(!find_section(f, section_id))
1101 {
1102 al_trace("Can't find section!\n");
1103 pack_fclose(f);
1104 clear_quest_tmpfile();
1105
1106 if(deletefilename[0])
1107 {
1108 delete_file(deletefilename);
1109 }
1110
1111 //setPackfilePassword(NULL);
1112 return false;
1113 }
1114
1115 switch(section_id)
1116 {
1117 case ID_RULES:
1118 //rules
1119 ret=readrules(f, Header, true);
1120 break;
1121
1122 case ID_STRINGS:
1123 //strings
1124 ret=readstrings(f, Header, true);
1125 break;
1126
1127 case ID_MISC:
1128 //misc data
1129 ret=readmisc(f, Header, Misc, true);
1130 break;
1131
1132 case ID_TILES:
1133 //tiles
1134 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1135 break;
1136
1137 case ID_COMBOS:
1138 //combos
1139 clear_combos();
1140 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1141 combosread=true;
1142 break;
1143
1144 case ID_COMBOALIASES:
1145 //combos
1146 ret=readcomboaliases(f, Header, version, build, true);
1147 break;
1148
1149 case ID_CSETS:
1150 //color data
1151 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1152 break;
1153
1154 case ID_MAPS:
1155 //maps
1156 ret=readmaps(f, Header, true);
1157 mapsread=true;
1158 break;
1159
1160 case ID_DMAPS:
1161 //dmaps
1162 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1163 break;
1164
1165 case ID_DOORS:
1166 //door combo sets
1167 ret=readdoorcombosets(f, Header, true);
1168 break;
1169
1170 case ID_ITEMS:
1171 //items
1172 ret=readitems(f, version, build, true);
1173 break;
1174
1175 case ID_WEAPONS:
1176 //weapons
1177 ret=readweapons(f, Header, true);
1178 break;
1179
1180 case ID_COLORS:
1181 //misc. colors
1182 ret=readmisccolors(f, Header, Misc, true);
1183 break;
1184
1185 case ID_ICONS:
1186 //game icons
1187 ret=readgameicons(f, Header, Misc, true);
1188 break;
1189
1190 case ID_INITDATA:
1191 //initialization data
1192 ret=readinitdata(f, Header, true);
1193 break;
1194
1195 case ID_GUYS:
1196 //guys
1197 ret=readguys(f, Header, true);
1198 break;
1199
1200 case ID_MIDIS:
1201 //midis
1202 ret=readtunes(f, Header, tunes, true);
1203 break;
1204
1205 case ID_CHEATS:
1206 //cheat codes
1207 ret=readcheatcodes(f, Header, true);
1208 break;
1209
1210 case ID_ITEMDROPSETS:
1211 //item drop sets
1212 // Why is this one commented out?
1213 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1214 break;
1215
1216 case ID_FAVORITES:
1217 // favorite combos and aliases
1218 ret=readfavorites(f, version, build, true);
1219 break;
1220
1221 default:
1222 ret=-1;
1223 break;
1224 }
1225
1226 pack_fclose(f);
1227 clear_quest_tmpfile();
1228
1229 if(deletefilename[0])
1230 {
1231 delete_file(deletefilename);
1232 }
1233
1234 //setPackfilePassword(NULL);
1235 if(!ret)
1236 {
1237 return true;
1238 }
1239
1240 return false;
1241 }
1242
1243 bool init_tiles(bool validate, zquestheader *Header)
1244 {
1245 return init_section(Header, ID_TILES, NULL, NULL, validate);
1246 }
1247
1248 bool init_combos(bool validate, zquestheader *Header)
1249 {
1250 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1251 }
1252
1253 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1254 {
1255 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1256 }
1257
1258 114 void init_spritelists()
1259 {
1260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(FFCore.quest_format[vZelda] < 0x255)
1261 {
1262 85 guys.setMax(255);
1263 85 items.setMax(255);
1264 85 Ewpns.setMax(255);
1265 85 Lwpns.setMax(255);
1266 85 Sitems.setMax(255);
1267 85 chainlinks.setMax(255);
1268 85 decorations.setMax(255);
1269 85 particles.setMax(255);
1270 85 }
1271 else
1272 {
1273 29 guys.setMax(255);
1274 29 items.setMax(255);
1275 29 Ewpns.setMax(255);
1276 29 Lwpns.setMax(255);
1277 29 Sitems.setMax(255);
1278 29 chainlinks.setMax(255);
1279 29 decorations.setMax(255);
1280 29 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1281 }
1282 114 }
1283
1284 38 bool reset_items(bool validate, zquestheader *Header)
1285 {
1286 38 bool ret = true;
1287
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (get_app_id() == App::zquest)
1288 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1289
1290
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9728 times.
9766 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1291
1292 38 return ret;
1293 }
1294
1295 bool reset_guys()
1296 {
1297 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1298 init_guys(V_GUYS);
1299 return true;
1300 }
1301
1302 bool reset_wpns(bool validate, zquestheader *Header)
1303 {
1304 bool ret = true;
1305 if (get_app_id() == App::zquest)
1306 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1307
1308 for(int32_t i=0; i<WPNCNT; i++)
1309 reset_weaponname(i);
1310
1311 return ret;
1312 }
1313
1314 bool reset_mapstyles(bool validate, miscQdata *Misc)
1315 {
1316 Misc->colors.blueframe_tile = 20044;
1317 Misc->colors.blueframe_cset = 0;
1318 Misc->colors.triforce_tile = 23461;
1319 Misc->colors.triforce_cset = 1;
1320 Misc->colors.triframe_tile = 18752;
1321 Misc->colors.triframe_cset = 1;
1322 Misc->colors.overworld_map_tile = 16990;
1323 Misc->colors.overworld_map_cset = 2;
1324 Misc->colors.HCpieces_tile = 21160;
1325 Misc->colors.HCpieces_cset = 8;
1326 Misc->colors.dungeon_map_tile = 19651;
1327 Misc->colors.dungeon_map_cset = 8;
1328 return true;
1329 }
1330
1331 38 int32_t get_qst_buffers()
1332 {
1333 38 memrequested+=(sizeof(mapscr)*MAPSCRS);
1334 38 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1335 38 TheMaps.resize(MAPSCRS);
1336
1337
2/2
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 38 times.
5206 for(int32_t i(0); i<MAPSCRS; i++)
1338 5168 TheMaps[i].zero_memory();
1339
1340 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1341 38 Z_message("OK\n"); // Allocating map buffer...
1342
1343 38 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1344 38 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1345
1346
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1347 return 0;
1348
1349 38 Z_message("OK\n");
1350
1351 // Allocating space for all 65535 strings uses up 10.62MB...
1352 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1353 // (Shoelace's "Hero of Dreams" uses 1415.)
1354 // So let's be a bit generous and allow 4096 initially.
1355 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1356 // I tested it and it worked without flaw on 6/6/11. - L.
1357 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1358 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1359 // See https://discord.com/channels/876899628556091432/992984989073416242
1360 38 msg_strings_size = 8192;
1361 38 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1362 38 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1363
1364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 MsgStrings = new MsgStr[msg_strings_size];
1365
1366 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1367
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38 times.
311334 for(auto q = 0; q < msg_strings_size; ++q)
1368 {
1369 311296 MsgStrings[q].clear();
1370 311296 }
1371 38 Z_message("OK\n"); // Allocating string buffer...
1372
1373 38 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1374 38 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1375
1376
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1377 return 0;
1378
1379 38 Z_message("OK\n"); // Allocating door combo buffer...
1380
1381 38 memrequested+=(sizeof(dmap)*MAXDMAPS);
1382 38 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1383
1384
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1385 return 0;
1386
1387 38 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1388 38 Z_message("OK\n"); // Allocating dmap buffer...
1389
1390 38 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1391 38 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1392
1393 38 combobuf.clear();
1394 38 combobuf.resize(MAXCOMBOS);
1395 38 Z_message("OK\n"); // Allocating combo buffer...
1396
1397 38 memrequested+=(psTOTAL255);
1398 38 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1399
1400
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1401 return 0;
1402
1403 38 Z_message("OK\n"); // Allocating color data buffer...
1404
1405 38 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1406 38 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1407
1408 38 free_newtilebuf();
1409
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1410 return 0;
1411
1412 38 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1413 //Z_message("Performed memset on tiles\n");
1414 38 clear_tiles(newtilebuf);
1415 //Z_message("Performed clear_tiles()\n");
1416 38 Z_message("OK\n"); // Allocating tile buffer...
1417
1418
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(is_zquest())
1419 {
1420 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1421 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1422
1423 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1424 return 0;
1425
1426 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1427 clear_tiles(grabtilebuf);
1428 Z_message("OK\n"); // Allocating tile grab buffer...
1429 }
1430
1431 38 memrequested+=(100000);
1432 38 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1433
1434
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((trashbuf=(byte*)malloc(100000))==NULL)
1435 return 0;
1436
1437 38 Z_message("OK\n"); // Allocating trash buffer...
1438
1439 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1440 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1441 // fixed by ensuring there's actually itemdata there.
1442 // If you change this, be sure to update del_qst_buffers, too.
1443
1444 38 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1445 38 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1446
1447
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1448 return 0;
1449
1450 38 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1451 38 itemsbuf++;
1452 38 Z_message("OK\n"); // Allocating item buffer...
1453
1454 38 memrequested+=(sizeof(wpndata)*MAXWPNS);
1455 38 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1456
1457
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1458 return 0;
1459
1460 38 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1461 38 Z_message("OK\n"); // Allocating weapon buffer...
1462
1463 38 memrequested+=(sizeof(guydata)*MAXGUYS);
1464 38 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1465
1466
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1467 return 0;
1468
1469 38 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1470 38 Z_message("OK\n"); // Allocating guy buffer...
1471
1472 38 memrequested+=(sizeof(comboclass)*cMAX);
1473 38 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1474
1475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1476 return 0;
1477
1478 38 Z_message("OK\n"); // Allocating combo class buffer...
1479
1480 38 return 1;
1481 38 }
1482
1483
1484 38 void free_newtilebuf()
1485 {
1486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(newtilebuf)
1487 {
1488 for(int32_t i=0; i<NEWMAXTILES; i++)
1489 if(newtilebuf[i].data)
1490 free(newtilebuf[i].data);
1491
1492 free(newtilebuf);
1493 newtilebuf = 0;
1494 }
1495 38 }
1496
1497 void free_grabtilebuf()
1498 {
1499 if(is_zquest())
1500 {
1501 if(grabtilebuf)
1502 {
1503 for(int32_t i=0; i<NEWMAXTILES; i++)
1504 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1505
1506 free(grabtilebuf);
1507 grabtilebuf = 0;
1508 }
1509 }
1510 }
1511
1512 void del_qst_buffers()
1513 {
1514 al_trace("Cleaning maps. \n");
1515
1516 if(ZCMaps) free(ZCMaps);
1517
1518 if(MsgStrings) delete[] MsgStrings;
1519
1520 if(DoorComboSets) free(DoorComboSets);
1521
1522 if(DMaps) free(DMaps);
1523
1524 combobuf.clear();
1525
1526 if(colordata) free(colordata);
1527
1528 al_trace("Cleaning tile buffers. \n");
1529 free_newtilebuf();
1530 free_grabtilebuf();
1531
1532 al_trace("Cleaning misc. \n");
1533
1534 if(trashbuf) free(trashbuf);
1535
1536 // See get_qst_buffers
1537 if(itemsbuf)
1538 {
1539 itemsbuf--;
1540 free(itemsbuf);
1541 }
1542
1543 if(wpnsbuf) free(wpnsbuf);
1544
1545 if(guysbuf) free(guysbuf);
1546
1547 if(combo_class_buf) free(combo_class_buf);
1548 }
1549
1550 4 bool init_palnames()
1551 {
1552 // if(palnames==NULL)
1553 // return false;
1554
1555
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1556 {
1557
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1558 {
1559 case 0:
1560 4 sprintf(palnames[x],"Overworld");
1561 4 break;
1562
1563 case 10:
1564 4 sprintf(palnames[x],"Caves");
1565 4 break;
1566
1567 case 11:
1568 4 sprintf(palnames[x],"Passageways");
1569 4 break;
1570
1571 default:
1572 2036 sprintf(palnames[x],"%c",0);
1573 2036 break;
1574 }
1575 2048 }
1576
1577 4 return true;
1578 }
1579
1580 21367 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1581 {
1582 void *p;
1583
1584
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 p = _AL_MALLOC(MAX(size, alloc_size));
1585
1586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21367 times.
21367 if(!p)
1587 {
1588 return NULL;
1589 }
1590
1591
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(!pfread(p,size,f,keepdata))
1592 {
1593 _AL_FREE(p);
1594 return NULL;
1595 }
1596
1597
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(pack_ferror(f))
1598 {
1599 _AL_FREE(p);
1600 return NULL;
1601 }
1602
1603 21367 return p;
1604 21367 }
1605
1606 /* read_midi:
1607 * Reads MIDI data from a datafile (this is not the same thing as the
1608 * standard midi file format).
1609 */
1610
1611 1875 static MIDI *read_midi(PACKFILE *f, bool)
1612 {
1613 MIDI *m;
1614 int32_t c;
1615 1875 int16_t divisions=0;
1616 1875 int32_t len=0;
1617
1618 1875 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1619
1620
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!m)
1621 {
1622 return NULL;
1623 }
1624
1625
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1626 {
1627 60000 m->track[c].len = 0;
1628 60000 m->track[c].data = NULL;
1629 60000 }
1630
1631 1875 p_mgetw(&divisions,f,true);
1632 1875 m->divisions=divisions;
1633
1634
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1635 {
1636 60000 p_mgetl(&len,f,true);
1637 60000 m->track[c].len=len;
1638
1639
2/2
✓ Branch 0 taken 38633 times.
✓ Branch 1 taken 21367 times.
60000 if(m->track[c].len > 0)
1640 {
1641 21367 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1642
1643
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(!m->track[c].data)
1644 {
1645 destroy_midi(m);
1646 return NULL;
1647 }
1648 21367 }
1649 60000 }
1650
1651 LOCK_DATA(m, sizeof(MIDI));
1652
1653
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1654 {
1655
2/2
✓ Branch 0 taken 21367 times.
✓ Branch 1 taken 38633 times.
60000 if(m->track[c].data)
1656 {
1657 LOCK_DATA(m->track[c].data, m->track[c].len);
1658 21367 }
1659 60000 }
1660
1661 1875 return m;
1662 1875 }
1663
1664 void clear_combo(int32_t i)
1665 {
1666 combobuf[i].clear();
1667 }
1668
1669 void clear_combos()
1670 {
1671 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1672 clear_combo(tmpcounter);
1673 }
1674
1675 void pack_combos()
1676 {
1677 int32_t di = 0;
1678
1679 for(int32_t si=0; si<1024; si+=2)
1680 combobuf[di++] = combobuf[si];
1681
1682 for(; di<1024; di++)
1683 clear_combo(di);
1684 }
1685
1686 114 void reset_tunes(zctune *tune)
1687 {
1688
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1689 {
1690 28728 tune[i].reset();
1691 28728 }
1692 114 }
1693
1694
1695 /*void reset_midi(zcmidi_ *m)
1696 {
1697 m->title[0]=0;
1698 m->loop=1;
1699 m->volume=144;
1700 m->start=0;
1701 m->loop_start=-1;
1702 m->loop_end=-1;
1703 if(m->midi)
1704 {
1705 destroy_midi(m->midi);
1706 }
1707 m->midi=NULL;
1708 }
1709
1710
1711 void reset_midis(zcmidi_ *m)
1712 {
1713 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1714 {
1715 reset_midi(m+i);
1716 }
1717 }
1718 */
1719
1720 void reset_scr(int32_t scr)
1721 {
1722 /*
1723 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1724 for(unsigned i=0; i<sizeof(mapscr); i++)
1725 *(di++) = 0;
1726 TheMaps[scr].valid=mVERSION;
1727 */
1728
1729 TheMaps[scr].zero_memory();
1730 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1731
1732 for(int32_t i=0; i<6; i++)
1733 {
1734 //these will be uncommented later
1735 //TheMaps[scr].layerxsize[i]=16;
1736 //TheMaps[scr].layerysize[i]=11;
1737 TheMaps[scr].layeropacity[i]=255;
1738 }
1739
1740 TheMaps[scr].valid=mVERSION;
1741
1742 }
1743
1744 /* For reference:
1745
1746 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1747 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1748 */
1749
1750 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1751 {
1752
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1753 {
1754
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1755 {
1756
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1757 {
1758
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1759 {
1760 1968 return false;
1761 }
1762
1763
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1764 {
1765 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1774 {
1775 return false;
1776 }
1777 58104 }
1778
1779
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1780 {
1781 return false;
1782 }
1783
1784
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1795 {
1796 return false;
1797 }
1798 87156 }
1799
1800
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1801 {
1802
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1803 {
1804 return false;
1805 }
1806
1807
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1823 {
1824 return false;
1825 }
1826 3228 }
1827
1828
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1829 {
1830
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1831 {
1832 return false;
1833 }
1834
1835
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1846 {
1847 return false;
1848 }
1849 4842 }
1850
1851
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1852 {
1853 return false;
1854 }
1855
1856
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1857 {
1858 return false;
1859 }
1860 14526 }
1861
1862 1614 return true;
1863 3582 }
1864
1865 int32_t doortranslations_u[9][4]=
1866 {
1867 {37,38,53,54},
1868 {37,38,39,40},
1869 {37,38,55,56},
1870 {37,38,39,40},
1871 {37,38,53,54},
1872 {37,38,53,54},
1873 {37,38,53,54},
1874 {7,8,23,24},
1875 {7,8,41,42}
1876 };
1877
1878 int32_t doortranslations_d[9][4]=
1879 {
1880 {117,118,133,134},
1881 {135,136,133,134},
1882 {119,120,133,134},
1883 {135,136,133,134},
1884 {117,118,133,134},
1885 {117,118,133,134},
1886 {117,118,133,134},
1887 {151,152,167,168},
1888 {137,138,167,168},
1889 };
1890
1891 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1892 int32_t doortranslations_l[9][6]=
1893 {
1894 {66,67,82,83,98,99},
1895 {66,68,82,84,98,100},
1896 {66,69,82,85,98,101},
1897 {66,68,82,84,98,100},
1898 {66,67,82,83,98,99},
1899 {66,67,82,83,98,99},
1900 {66,67,82,83,98,99},
1901 {64,65,80,81,96,97},
1902 {64,65,80,114,96,97},
1903 };
1904
1905 int32_t doortranslations_r[9][6]=
1906 {
1907
1908 {76,77,92,93,108,109},
1909 {75,77,91,93,107,109},
1910 {74,77,90,93,106,109},
1911 {75,77,91,93,107,109},
1912 {76,77,92,93,108,109},
1913 {76,77,92,93,108,109},
1914 {76,77,92,93,108,109},
1915 {78,79,94,95,110,111},
1916 {78,79,125,95,110,111},
1917 };
1918
1919 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1920 {
1921 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1922 }
1923
1924 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 //these are here to bypass compiler warnings about unused arguments
1927 308180 map=map;
1928 308180 scr=scr;
1929 308180 pos=pos;
1930
1931 //what does this function do?
1932 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1933 308180 return 2;
1934 }
1935
1936 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1937 {
1938
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1939 {
1940 5450 return 0;
1941 }
1942
1943 DoorComboSet tempdcs;
1944 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1945
1946 //up
1947
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1948 {
1949
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1950 {
1951 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1952 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1953 58392 }
1954 14598 }
1955
1956 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1957 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1958 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1959 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1960 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1961 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1962
1963 //down
1964
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1965 {
1966
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1967 {
1968 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1969 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1970 58392 }
1971 14598 }
1972
1973 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1974
1975 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1976 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1977 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1978 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1979 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1980
1981 //left
1982 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1983
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1984 {
1985
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1986 {
1987 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1988 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1989 87588 }
1990 14598 }
1991
1992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1993 {
1994 if((j!=2)&&(j!=3))
1995 {
1996 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1997 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1998 }
1999 }
2000
2001 1622 tempdcs.bombdoorcombo_l[0]=0;
2002 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2003 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2004 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2005 1622 tempdcs.bombdoorcombo_l[2]=0;
2006 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2007 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2008 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2009
2010 //right
2011
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2012 {
2013
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2014 {
2015 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2016 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2017 87588 }
2018 14598 }
2019
2020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2021 {
2022 if((j!=2)&&(j!=3))
2023 {
2024 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2025 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2026 }
2027 }
2028
2029 1622 tempdcs.bombdoorcombo_r[0]=0;
2030 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2031 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2032 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2033 1622 tempdcs.bombdoorcombo_r[2]=0;
2034 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2035 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2036 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2037
2038 int32_t k;
2039
2040
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2041 {
2042
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2043 {
2044 1614 break;
2045 }
2046 1968 }
2047
2048
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2049 {
2050 8 DoorComboSets[k]=tempdcs;
2051 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2052 8 ++door_combo_set_count;
2053 8 }
2054
2055 1622 return k;
2056 /*
2057 doorcombo_u[9][4];
2058 doorcset_u[9][4];
2059 doorcombo_d[9][4];
2060 doorcset_d[9][4];
2061 doorcombo_l[9][6];
2062 doorcset_l[9][6];
2063 doorcombo_r[9][6];
2064 doorcset_r[9][6];
2065 bombdoorcombo_u[2];
2066 bombdoorcset_u[2];
2067 bombdoorcombo_d[2];
2068 bombdoorcset_d[2];
2069 bombdoorcombo_l[3];
2070 bombdoorcset_l[3];
2071 bombdoorcombo_r[3];
2072 bombdoorcset_r[3];
2073 walkthroughcombo[4];
2074 walkthroughcset[4];
2075 */
2076 7072 }
2077
2078 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2079 {
2080 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2081 }
2082
2083 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2084 {
2085
2086 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2087 }
2088
2089 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2090 {
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2092 }
2093
2094
2095 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2096 {
2097 char temp_pwd[30];
2098 9 memset(temp_pwd,0,30);
2099
2100
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2101 {
2102 9 memcpy(temp_pwd,encrypted_pwd,30);
2103 9 temp_pwd[29]=0;
2104
2105
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2106 {
2107 270 temp_pwd[i] -= pwdkey;
2108 270 int32_t t=pwdkey>>15;
2109 270 pwdkey = (pwdkey<<1)+t;
2110 270 }
2111 9 }
2112
2113 9 memcpy(pwd,temp_pwd,30);
2114 9 }
2115
2116
2117 85 bool devpwd()
2118 {
2119 #ifdef _DEBUG
2120 return true;
2121 #endif
2122 85 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2123 }
2124 bool check_questpwd(zquestheader *Header, char *pwd)
2125 {
2126 #if DEVLEVEL > 3
2127 return true;
2128 #endif
2129
2130 if (devpwd()) return true;
2131 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2132 cvs_MD5Context ctx;
2133 uint8_t md5sum[16];
2134
2135 cvs_MD5Init(&ctx);
2136 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2137 cvs_MD5Final(md5sum, &ctx);
2138
2139 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2140 }
2141
2142 106 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2143 {
2144 106 zprint2("\n");
2145 106 zprint2("[ZQUEST CREATOR METADATA]\n");
2146
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(qst_num < moduledata.max_quest_files)
2147 zprint2("Loading module quest %d\n", qst_num+1);
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(path) zprint2("Loading '%s'\n", path);
2149
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 4 times.
106 if ( tempheader.new_version_id_main > 0 )
2150 {
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(tempheader.new_version_id_fourth > 0)
2152 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2153 tempheader.new_version_id_main,tempheader.new_version_id_second,
2154 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2155 102 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2156 102 tempheader.new_version_id_main,tempheader.new_version_id_second,
2157 102 tempheader.new_version_id_third);
2158 102 }
2159 else
2160 {
2161
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2162 {
2163 case 0x255:
2164 {
2165 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2166 break;
2167 }
2168 case 0x254:
2169 {
2170 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2171 break;
2172 }
2173 case 0x250:
2174 {
2175 switch(tempheader.build)
2176 {
2177 case 19:
2178 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2179 case 20:
2180 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2181 case 21:
2182 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2183 case 22:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2185 case 23:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2187 case 24:
2188 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2189 case 25:
2190 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2191 case 26:
2192 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2193 case 27:
2194 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2195 case 28:
2196 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2197 case 29:
2198 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2199 case 30:
2200 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2201 case 31:
2202 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2203 case 32:
2204 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2205 case 33:
2206 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2207 default:
2208 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2209
2210 }
2211 break;
2212 }
2213
2214 case 0x211:
2215 {
2216 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2217 }
2218 case 0x210:
2219 {
2220 zprint2("Last saved in ZQuest Version: 2.10.x");
2221 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2222 break;
2223 }
2224 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2225 case 0x193:
2226 {
2227 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2228 }
2229 case 0x192:
2230 {
2231 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2232 }
2233 case 0x190:
2234 {
2235 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2236 }
2237 case 0x184:
2238 {
2239 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2240 }
2241 case 0x183:
2242 {
2243 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2244 }
2245 case 0x180:
2246 {
2247 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2248 }
2249 default:
2250 {
2251 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2252 }
2253 */
2254 }
2255 }
2256
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
106 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2257 21 zprint2("%s\n", tempheader.getAlphaVerStr());
2258 85 else zprint2("\n");
2259
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2261
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2262
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2263
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 102 times.
106 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2264
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2265 106 zprint2("\n");
2266 106 }
2267
2268 114 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2269 {
2270 int32_t dummy;
2271 zquestheader tempheader;
2272 char dummybuf[80];
2273 byte temp_map_count;
2274 byte temp_midi_flags[MIDIFLAGS_SIZE];
2275 word version;
2276 char temp_pwd[30], temp_pwd2[30];
2277 int16_t temp_pwdkey;
2278 cvs_MD5Context ctx;
2279 114 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2280 114 memset(&tempheader, 0, sizeof(tempheader));
2281 114 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2282
2283
2284
2285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2286 {
2287 Z_message("Unable to read header string\n");
2288 return qe_invalid;
2289 }
2290
2291 // check header
2292
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2293 {
2294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2295 {
2296 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2297 return qe_invalid;
2298 }
2299 4 }
2300
2301 114 int32_t templatepath_len=0;
2302
2303 114 tempheader.external_zinfo = false;
2304 114 read_zinfo = false;
2305
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2306 {
2307 byte padding;
2308
2309
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2310 {
2311 return qe_invalid;
2312 }
2313
2314
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2315 {
2316 return qe_invalid;
2317 }
2318
2319 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2320
2321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2322 {
2323 return qe_version;
2324 }
2325
2326 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2327
2328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2329 {
2330 return qe_invalid;
2331 }
2332
2333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2334 {
2335 return qe_obsolete;
2336 }
2337
2338
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2339 {
2340 return qe_invalid;
2341 }
2342
2343
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2344 {
2345 return qe_invalid;
2346 }
2347
2348 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2349
2350
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2351 {
2352 return qe_invalid;
2353 }
2354
2355
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2356 {
2357 return qe_invalid;
2358 }
2359
2360 4 FFCore.quest_format[qMapCount] = temp_map_count;
2361
2362
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2363 {
2364 return qe_invalid;
2365 }
2366
2367
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2368 {
2369 return qe_invalid;
2370 }
2371
2372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2373 {
2374 return qe_invalid;
2375 }
2376
2377
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2378 {
2379 return qe_invalid;
2380 }
2381
2382
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2383 {
2384 return qe_invalid;
2385 }
2386
2387
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2388 {
2389 return qe_invalid;
2390 }
2391
2392
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2393 {
2394 return qe_invalid;
2395 }
2396
2397
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2398 {
2399 return qe_invalid;
2400 }
2401
2402
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2403 {
2404 return qe_invalid;
2405 }
2406 // These fields are expected to end in null bytes!
2407 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2408
2409
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2410 {
2411 return qe_invalid;
2412 }
2413 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2414
2415
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2416 {
2417 return qe_invalid;
2418 }
2419
2420
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2421 {
2422 return qe_invalid;
2423 }
2424
2425
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2426 {
2427 return qe_invalid;
2428 }
2429
2430 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2431 4 cvs_MD5Init(&ctx);
2432 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2433 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2434
2435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2436 {
2437 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2438 // Not anymore...
2439 memset(tempheader.minver,0,17);
2440 tempheader.build=0;
2441 tempheader.use_keyfile=0;
2442 memset(tempheader.old_foo, 0, 9);
2443 }
2444 else
2445 {
2446
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2447 {
2448 return qe_invalid;
2449 }
2450
2451
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2452 {
2453 return qe_invalid;
2454 }
2455
2456 4 FFCore.quest_format[vBuild] = tempheader.build;
2457
2458
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2459 {
2460 return qe_invalid;
2461 }
2462
2463
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2464 {
2465 return qe_invalid;
2466 }
2467 } // starting at minver
2468
2469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2470 {
2471 memset(&quest_rules[4],0,16); // word rules3..rules10
2472 }
2473 else
2474 {
2475
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2476 {
2477 return qe_invalid; // starting at rules3
2478 }
2479
2480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2481 {
2482 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2483 4 }
2484 }
2485
2486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2487 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2488 {
2489 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2490 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2491 4 }
2492
2493
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2494 {
2495 byte *mf=temp_midi_flags;
2496
2497 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2498 {
2499 mf=(byte*)dummybuf;
2500 }
2501
2502 if(!pfread(mf,32,f,true)) // read new header additions
2503 {
2504 return qe_invalid; // starting at foo2
2505 }
2506
2507 if(!pfread(dummybuf,18,f,true)) // read new header additions
2508 {
2509 return qe_invalid; // starting at foo2
2510 }
2511 }
2512
2513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2514 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2515 {
2516 4 memset(tempheader.templatepath,0,2048);
2517 4 }
2518 else
2519 {
2520 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2521 {
2522 return qe_invalid;
2523 }
2524 }
2525
2526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2527 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2528 {
2529 4 tempheader.use_keyfile=0;
2530 4 }
2531 4 }
2532 else
2533 {
2534 //section id
2535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_mgetl(&dummy,f,true))
2536 {
2537 return qe_invalid;
2538 }
2539
2540 //section version info
2541
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&version,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 110 FFCore.quest_format[vHeader] = version;
2547
2548
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
2549 {
2550 return qe_invalid;
2551 }
2552
2553 //section size
2554
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
2555 {
2556 return qe_invalid;
2557 }
2558
2559 //finally... section data
2560
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&tempheader.zelda_version,f,true))
2561 {
2562 return qe_invalid;
2563 }
2564
2565 110 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2566
2567 //do some quick checking...
2568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(tempheader.zelda_version > ZELDA_VERSION)
2569 {
2570 return qe_version;
2571 }
2572
2573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2574 {
2575 return qe_invalid;
2576 }
2577
2578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(bad_version(tempheader.zelda_version))
2579 {
2580 return qe_obsolete;
2581 }
2582
2583
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.build,f,true))
2584 {
2585 return qe_invalid;
2586 }
2587
2588 110 FFCore.quest_format[vBuild] = tempheader.build;
2589
2590
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(version<3)
2591 {
2592
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2593 {
2594 return qe_invalid;
2595 }
2596
2597
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
2602 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2603 5 cvs_MD5Init(&ctx);
2604 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2605 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2606 5 }
2607 else
2608 {
2609
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2610 {
2611 return qe_invalid;
2612 }
2613 }
2614
2615
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&tempheader.internal,f,true))
2616 {
2617 return qe_invalid;
2618 }
2619
2620
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.quest_number,f,true))
2621 {
2622 return qe_invalid;
2623 }
2624
2625 110 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2626
2627 110 size_t versz = version < 8 ? 9 : 16;
2628
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.version,versz,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
2633 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2634 //needs to be copied as char[9] or stored as a s.str
2635
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.minver,versz,f,true))
2636 {
2637 return qe_invalid;
2638 }
2639
2640 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2641
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2642 {
2643 return qe_invalid;
2644 }
2645 110 tempheader.title[sizeof(tempheader.title)-1] = 0;
2646
2647
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2648 {
2649 return qe_invalid;
2650 }
2651 110 tempheader.author[sizeof(tempheader.author)-1] = 0;
2652
2653
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.use_keyfile,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
2658 /*
2659 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2660 {
2661 return qe_invalid;
2662 }
2663 */
2664
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2665 {
2666 return qe_invalid;
2667 }
2668
2669
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(&dummybuf,4,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673
2674
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2675 {
2676 return qe_invalid;
2677 }
2678
2679
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(dummybuf,14,f,true))
2680 {
2681 return qe_invalid;
2682 }
2683
2684 110 templatepath_len=sizeof(tempheader.templatepath);
2685
2686
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(version==1)
2687 {
2688 5 templatepath_len=280;
2689 5 }
2690
2691
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2692 {
2693 return qe_invalid;
2694 }
2695
2696
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&temp_map_count,f,true))
2697 {
2698 return qe_invalid;
2699 }
2700
2701
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(version>=4)
2702 {
2703
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2704 {
2705 return qe_invalid;
2706 }
2707
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2708 {
2709 return qe_invalid;
2710 }
2711
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2712 {
2713 return qe_invalid;
2714 }
2715
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2716 {
2717 return qe_invalid;
2718 }
2719
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2720 {
2721 return qe_invalid;
2722 }
2723
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2724 {
2725 return qe_invalid;
2726 }
2727
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2728 {
2729 return qe_invalid;
2730 }
2731
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2732 {
2733 return qe_invalid;
2734 }
2735
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2736 {
2737 return qe_invalid;
2738 }
2739
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2740 {
2741 return qe_invalid;
2742 }
2743
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2744 {
2745 return qe_invalid;
2746 }
2747
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2748 {
2749 return qe_invalid;
2750 }
2751
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2752 {
2753 return qe_invalid;
2754 }
2755
2756
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_devsig,256,f,true))
2757 {
2758 return qe_invalid;
2759 }
2760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2761 strcpy(tempheader.new_version_devsig, "EmilyV99");
2762
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_compilername,256,f,true))
2763 {
2764 return qe_invalid;
2765 }
2766
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2767 {
2768 return qe_invalid;
2769 }
2770
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.product_name,1024,f,true))
2771 {
2772 return qe_invalid;
2773 }
2774
2775
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.compilerid,f,true))
2776 {
2777 return qe_invalid;
2778 }
2779
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2780 {
2781 return qe_invalid;
2782 }
2783
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2784 {
2785 return qe_invalid;
2786 }
2787
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2788 {
2789 return qe_invalid;
2790 }
2791
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2792 {
2793 return qe_invalid;
2794 }
2795
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&tempheader.developerid,f,true))
2796 {
2797 return qe_invalid;
2798 }
2799
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2800 {
2801 return qe_invalid;
2802 }
2803
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.build_datestamp,256,f,true))
2804 {
2805 return qe_invalid;
2806 }
2807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!pfread(tempheader.build_timestamp,256,f,true))
2808 {
2809 return qe_invalid;
2810 }
2811 29 }
2812 else // <4
2813 {
2814 81 tempheader.new_version_id_main = 0;
2815 81 tempheader.new_version_id_second = 0;
2816 81 tempheader.new_version_id_third = 0;
2817 81 tempheader.new_version_id_fourth = 0;
2818 81 tempheader.new_version_id_alpha = 0;
2819 81 tempheader.new_version_id_beta = 0;
2820 81 tempheader.new_version_id_gamma = 0;
2821 81 tempheader.new_version_id_release = 0;
2822 81 tempheader.new_version_id_date_year = 0;
2823 81 tempheader.new_version_id_date_month = 0;
2824 81 tempheader.new_version_id_date_day = 0;
2825 81 tempheader.new_version_id_date_hour = 0;
2826 81 tempheader.new_version_id_date_minute = 0;
2827
2828 81 memset(tempheader.new_version_devsig, 0, 256);
2829 81 memset(tempheader.new_version_compilername, 0, 256);
2830 81 memset(tempheader.new_version_compilerversion, 0, 256);
2831 81 memset(tempheader.product_name, 0, 1024);
2832 81 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2833
2834 81 tempheader.compilerid = 0;
2835 81 tempheader.compilerversionnumber_first = 0;
2836 81 tempheader.compilerversionnumber_second = 0;
2837 81 tempheader.compilerversionnumber_third = 0;
2838 81 tempheader.compilerversionnumber_fourth = 0;
2839 81 tempheader.developerid = 0;
2840
2841 81 memset(tempheader.made_in_module_name, 0, 1024);
2842 81 memset(tempheader.build_datestamp, 0, 256);
2843 81 memset(tempheader.build_timestamp, 0, 256);
2844 }
2845
2846
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( version >= 5 )
2847 {
2848
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.build_timezone,6,f,true))
2849 {
2850 return qe_invalid;
2851 }
2852 29 }
2853 else // < 5
2854 {
2855 81 memset(tempheader.build_timezone, 0, 6);
2856 }
2857
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if ( version >= 6 )
2858 {
2859 byte b;
2860
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&b,f,true))
2861 {
2862 return qe_invalid;
2863 }
2864 29 tempheader.external_zinfo = b?true:false;
2865 29 read_zinfo = true;
2866 29 }
2867
2868
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(version >= 7)
2869 {
2870
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2871 {
2872 return qe_invalid;
2873 }
2874 29 }
2875 else
2876 {
2877 81 tempheader.new_version_is_nightly = false;
2878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(tempheader.zelda_version < 0x255)
2879 {
2880
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
81 switch(tempheader.zelda_version)
2881 {
2882 case 0x254:
2883 tempheader.new_version_id_main = 2;
2884 tempheader.new_version_id_second = 54;
2885 break;
2886 case 0x250:
2887
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 1 times.
76 switch(tempheader.build)
2888 {
2889 case 19:
2890 tempheader.new_version_id_main = 2;
2891 tempheader.new_version_id_second = 50;
2892 tempheader.new_version_id_gamma = 1;
2893 break;
2894 case 20:
2895 tempheader.new_version_id_main = 2;
2896 tempheader.new_version_id_second = 50;
2897 tempheader.new_version_id_gamma = 2;
2898 break;
2899 case 21:
2900 tempheader.new_version_id_main = 2;
2901 tempheader.new_version_id_second = 50;
2902 tempheader.new_version_id_gamma = 3;
2903 break;
2904 case 22:
2905 tempheader.new_version_id_main = 2;
2906 tempheader.new_version_id_second = 50;
2907 tempheader.new_version_id_gamma = 4;
2908 break;
2909 case 23:
2910 tempheader.new_version_id_main = 2;
2911 tempheader.new_version_id_second = 50;
2912 tempheader.new_version_id_gamma = 5;
2913 break;
2914 case 24:
2915 22 tempheader.new_version_id_main = 2;
2916 22 tempheader.new_version_id_second = 50;
2917 22 tempheader.new_version_id_release = -1;
2918 22 break;
2919 case 25:
2920 tempheader.new_version_id_main = 2;
2921 tempheader.new_version_id_second = 50;
2922 tempheader.new_version_id_third = 1;
2923 tempheader.new_version_id_gamma = 1;
2924 break;
2925 case 26:
2926 tempheader.new_version_id_main = 2;
2927 tempheader.new_version_id_second = 50;
2928 tempheader.new_version_id_third = 1;
2929 tempheader.new_version_id_gamma = 2;
2930 break;
2931 case 27:
2932 tempheader.new_version_id_main = 2;
2933 tempheader.new_version_id_second = 50;
2934 tempheader.new_version_id_third = 1;
2935 tempheader.new_version_id_gamma = 3;
2936 break;
2937 case 28:
2938 5 tempheader.new_version_id_main = 2;
2939 5 tempheader.new_version_id_second = 50;
2940 5 tempheader.new_version_id_third = 1;
2941 5 tempheader.new_version_id_release = -1;
2942 5 break;
2943 case 29:
2944 24 tempheader.new_version_id_main = 2;
2945 24 tempheader.new_version_id_second = 50;
2946 24 tempheader.new_version_id_third = 2;
2947 24 tempheader.new_version_id_release = -1;
2948 24 break;
2949 case 30:
2950 tempheader.new_version_id_main = 2;
2951 tempheader.new_version_id_second = 50;
2952 tempheader.new_version_id_third = 3;
2953 tempheader.new_version_id_gamma = 1;
2954 break;
2955 case 31:
2956 15 tempheader.new_version_id_main = 2;
2957 15 tempheader.new_version_id_second = 53;
2958 15 tempheader.new_version_id_gamma = -1;
2959 15 break;
2960 case 32:
2961 9 tempheader.new_version_id_main = 2;
2962 9 tempheader.new_version_id_second = 53;
2963 9 tempheader.new_version_id_release = -1;
2964 9 break;
2965 case 33:
2966 1 tempheader.new_version_id_main = 2;
2967 1 tempheader.new_version_id_second = 53;
2968 1 tempheader.new_version_id_third = 1;
2969 1 break;
2970 }
2971 76 break;
2972
2973 case 0x211:
2974 tempheader.new_version_id_main = 2;
2975 tempheader.new_version_id_second = 11;
2976 tempheader.new_version_id_beta = tempheader.build;
2977 break;
2978 case 0x210:
2979 5 tempheader.new_version_id_main = 2;
2980 5 tempheader.new_version_id_second = 10;
2981 5 tempheader.new_version_id_beta = tempheader.build;
2982 5 break;
2983 }
2984 81 }
2985 }
2986
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(printmetadata || __isZQuest)
2987 {
2988 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2989 }
2990 }
2991
2992 //{ Version Warning
2993 114 int32_t vercmp = tempheader.compareVer();
2994 114 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2995 114 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2996
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
143 if(vercmp > 0 || (!vercmp &&
2997
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 (astatecmp > 0 || (!astatecmp &&
2998 29 avercmp > 0))))
2999 {
3000 bool r = true;
3001 if(loadquest_report)
3002 {
3003 enter_sys_pal();
3004 AlertDialog("Quest saved in newer version",
3005 "This quest was last saved in a newer version of ZQuest."
3006 " Attempting to load this quest may not work correctly; to"
3007 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3008 "\n\nWould you like to continue loading anyway? (Not recommended)",
3009 [&](bool ret,bool)
3010 {
3011 r = ret;
3012 }).show();
3013 exit_sys_pal();
3014 }
3015 if(!r)
3016 return qe_silenterr;
3017 }
3018
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 11 times.
114 else if(tempheader.compareDate() > 0)
3019 {
3020 11 bool r = true;
3021
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(loadquest_report)
3022 {
3023 enter_sys_pal();
3024 AlertDialog("Quest saved in newer build",
3025 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3026 " issues loading in this build."
3027 "\n{}"
3028 "\n\nWould you like to continue loading anyway?",
3029 tempheader.getVerCmpStr()),
3030 [&](bool ret,bool)
3031 {
3032 r = ret;
3033 }).show();
3034 exit_sys_pal();
3035 }
3036
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!r)
3037 return qe_silenterr;
3038 11 }
3039 //}
3040
3041 114 read_ext_zinfo = tempheader.external_zinfo;
3042
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
3044 {
3045 114 memcpy(Header, &tempheader, sizeof(tempheader));
3046 114 map_count=temp_map_count;
3047 114 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3048 114 }
3049
3050 114 return 0;
3051 114 }
3052
3053 116 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3054 {
3055 int32_t dummy;
3056 zquestheader tempheader;
3057 116 word s_version=0;
3058 116 dword compatrule_version=0;
3059
3060 116 memcpy(&tempheader, Header, sizeof(tempheader));
3061
3062
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 110 times.
116 if(tempheader.zelda_version >= 0x193)
3063 {
3064 //section version info
3065
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
3066 {
3067 return qe_invalid;
3068 }
3069
3070 110 FFCore.quest_format[vRules] = s_version;
3071
3072
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
3073 {
3074 return qe_invalid;
3075 }
3076
3077
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version > 16)
3078 {
3079
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&compatrule_version,f,true))
3080 {
3081 return qe_invalid;
3082 }
3083 29 }
3084 110 FFCore.quest_format[vCompatRule] = compatrule_version;
3085
3086 //section size
3087
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
3088 {
3089 return qe_invalid;
3090 }
3091
3092
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if ( s_version < 15 )
3093 {
3094 //finally... section data
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3096 {
3097 return qe_invalid;
3098 }
3099 81 }
3100 else
3101 {
3102
3103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3104 {
3105 return qe_invalid;
3106 }
3107
3108 }
3109 110 }
3110
3111 //al_trace("Rules version %d\n", s_version);
3112 //{ bunch of compat stuff
3113 116 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3114
3115
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(s_version<2)
3116 {
3117 9 set_bit(quest_rules,14,0);
3118 9 set_bit(quest_rules,27,0);
3119 9 set_bit(quest_rules,28,0);
3120 9 set_bit(quest_rules,29,0);
3121 9 set_bit(quest_rules,30,0);
3122 9 set_bit(quest_rules,32,0);
3123 9 set_bit(quest_rules,36,0);
3124 9 set_bit(quest_rules,49,0);
3125 9 set_bit(quest_rules,50,0);
3126 9 set_bit(quest_rules,51,0);
3127 9 set_bit(quest_rules,68,0);
3128 9 set_bit(quest_rules,75,0);
3129 9 set_bit(quest_rules,76,0);
3130 9 set_bit(quest_rules,98,0);
3131 9 set_bit(quest_rules,110,0);
3132 9 set_bit(quest_rules,113,0);
3133 9 set_bit(quest_rules,116,0);
3134 9 set_bit(quest_rules,102,0);
3135 9 set_bit(quest_rules,132,0);
3136 9 }
3137
3138 //Now, do any updates...
3139
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3140 {
3141 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3142 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3143 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3144 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3145 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3146 13 }
3147
3148
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3149 {
3150 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3151 8 }
3152
3153
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3154 {
3155 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3156 8 }
3157
3158
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3159 {
3160 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3161 8 }
3162
3163
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version <= 0x210)
3164 {
3165 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3166 9 }
3167
3168
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 5 times.
116 if(tempheader.zelda_version == 0x210)
3169 {
3170 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3171 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3172 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3173 5 }
3174
3175
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version <= 0x210)
3176 {
3177 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3178 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3179 9 }
3180
3181 //might not be correct
3182
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if(tempheader.zelda_version < 0x210)
3183 {
3184 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3185 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3186 4 }
3187
3188
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version < 0x211)
3189 {
3190 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3191 9 }
3192
3193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3194 {
3195 set_bit(quest_rules, qr_192b163_WARP,1);
3196 }
3197
3198
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 5 times.
116 if(tempheader.zelda_version == 0x210)
3199 {
3200 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3201 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3202 5 }
3203
3204
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3205 {
3206 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3207 13 }
3208
3209
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3210 {
3211 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3212 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3213 13 }
3214
3215
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3216 {
3217 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3218 9 }
3219
3220
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 22 times.
116 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3221 {
3222 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3223 22 }
3224
3225
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3226 {
3227 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3228 13 }
3229
3230
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3231 {
3232 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3233 13 }
3234
3235
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3236 {
3237 35 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3238 35 }
3239
3240
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3241 {
3242 35 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3243 35 }
3244
3245 //Bombchu fix.
3246
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 76 times.
116 if(tempheader.zelda_version == 0x250)
3247 {
3248
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 22 times.
76 if ( tempheader.build == 24 ) //2.50.0
3249 {
3250 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3251 22 }
3252
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 5 times.
76 if ( tempheader.build == 28 ) //2.50.1
3253 {
3254 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3255 5 }
3256
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
76 if ( tempheader.build == 29 ) //2.50.2
3257 {
3258 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3259 24 }
3260
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( tempheader.build == 30 ) //2.50.3RC1
3261 {
3262 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3263 }
3264 76 }
3265
3266
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 51 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3267 {
3268 // qr_OFFSETEWPNCOLLISIONFIX
3269 // All 'official' quests need this disabled.
3270 // All 2.10 and lower quests need this enabled to preseve compatability.
3271 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3272
3273 //~Gleeok
3274 36 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3275
3276 // Broke in build 695
3277
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
36 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3278 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3279 36 }
3280
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if (tempheader.zelda_version <= 0x190)
3281 {
3282 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3283 4 }
3284
9/10
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 29 times.
116 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3285 {
3286 86 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3287 86 }
3288
3289
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3290 {
3291 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3292 9 }
3293
3294
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3295 {
3296 85 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3297 85 }
3298
3299
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( tempheader.zelda_version < 0x250 )
3300 {
3301 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3302 9 }
3303
3304
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 3)
3305 {
3306 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3307 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3308 9 }
3309
3310
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<4)
3311 {
3312 9 set_bit(quest_rules,10,0);
3313 9 }
3314
3315
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<5)
3316 {
3317 9 set_bit(quest_rules,27,0);
3318 9 }
3319
3320
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<6)
3321 {
3322 9 set_bit(quest_rules,46,0);
3323 9 }
3324
3325
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<7) // January 2008
3326 {
3327 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3328 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3329 9 }
3330
3331
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version<8)
3332 {
3333 9 set_bit(quest_rules, 12, 0);
3334 9 }
3335 else
3336 {
3337 105 set_bit(deprecated_rules, 12, 0);
3338 }
3339
3340
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<9) // October 2008
3341 {
3342 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3343 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3344 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3345 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3346 9 }
3347
3348
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<10) // December 2008
3349 {
3350 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3351 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3352 9 }
3353
3354
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<11) // April 2009
3355 {
3356 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3357 9 }
3358
3359
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<12) // December 2009
3360 {
3361 9 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3362 9 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3363 9 }
3364
3365 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3366
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 13)
3367 {
3368 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3369 9 }
3370
3371 // Not entirely sure this is the best place for this...
3372 //2.50.2 bitmap offset fix
3373 114 memset(extra_rules, 0, EXTRARULES_SIZE);
3374
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 49 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3375 {
3376 36 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3377 36 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3378 36 }
3379 //required because quest templates also used this bit, although
3380 //it never did anything, before. -Z
3381
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 76 times.
114 if ( tempheader.zelda_version == 0x250 )
3382 {
3383
5/6
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 37 times.
76 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3384 {
3385 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3386 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3387 39 }
3388 76 }
3389
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if ( tempheader.zelda_version == 0x254 )
3390 {
3391 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3392 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3393 }
3394
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
114 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3395 {
3396 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3397 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3398 }
3399 //optimise fast drawing for older versions.
3400
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3401 {
3402 85 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3403 85 }
3404 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3405 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3406 //older quests can set the rule by hand. We need a new qst.dat again.
3407
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3408 {
3409 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3410 }
3411
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3412 {
3413 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3414 }
3415
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3416 {
3417 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3418 }
3419
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x254 )
3420 {
3421 85 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3422 85 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3423 85 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3424 85 }
3425
3426 //item scripts continue to run
3427
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3428 {
3429 85 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3430 85 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3431 85 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3432 85 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3433 85 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3434 85 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3435 85 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3436 85 }
3437
3438
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3439 {
3440 85 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3441 85 }
3442
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3443 {
3444 85 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3445 85 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3446 85 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3447 85 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3448 85 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3449 85 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3450 85 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3451 85 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3452
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 2 times.
85 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3453 {
3454 2 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3455 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3456 //Now they **do**, unless you disable that behaviour.
3457 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3458 //now enable the disable L/R item swap on load.
3459 2 }
3460
3461 85 }
3462
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3463 {
3464 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3465 85 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3466 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3467 //animations ending earlier than they should.
3468 85 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3469 //Enemies would ignore solidity on the top half of combos
3470 85 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3471 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3472 85 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3473 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3474 85 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3475 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3476 85 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3477 85 }
3478
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x255 )
3479 {
3480 85 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3481 85 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3482 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3483 85 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3484 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3485 85 }
3486
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3487 {
3488 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3489 85 }
3490
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3491 {
3492 85 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3493 85 }
3494
3495
3496
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3497 {
3498 85 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3499 85 }
3500
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3501 {
3502 85 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3503 85 }
3504
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3505 {
3506 85 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3507 85 }
3508
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3509 {
3510 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3511
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3512 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3513 85 }
3514
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3515 {
3516 85 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3517 85 }
3518
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3519 {
3520 85 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3521 85 }
3522
3523
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x254 )
3524 {
3525 85 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3526 85 }
3527 //Sideview spikes in 2.50.0
3528
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 54 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3529 {
3530 31 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3531 31 }
3532 //more 2.50 fixes -Z
3533
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 25 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3534 {
3535 60 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3536 60 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3537 60 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3538 60 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3539 60 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3540
3541 60 }
3542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3543 {
3544 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3545 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3546 }
3547
3548
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(tempheader.zelda_version < 0x193)
3549 {
3550 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3551 4 }
3552
3553
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(tempheader.zelda_version < 0x255)
3554 {
3555 85 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3556 85 }
3557
3558
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3559 {
3560 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3561 9 }
3562
3563
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3564 {
3565 85 set_bit(quest_rules,qr_OLD_F6,1);
3566 85 }
3567
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3568 {
3569 85 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3570 85 }
3571
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3572 {
3573 85 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3574 85 }
3575
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3576 {
3577 85 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3578 85 }
3579 //}
3580
3581
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3582 85 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3583
3584
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 2) //Old CSet2 Handling
3585 85 set_bit(quest_rules,qr_OLDCS2,1);
3586
3587
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3588 85 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3589
3590
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3591 85 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3592
3593
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 76 times.
114 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3594 76 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3595
3596
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3597 85 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3598
3599
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3600 85 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3601
3602
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3603 85 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3604
3605
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 9)
3606 {
3607 //Hardcoded BS Patras
3608 85 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3609 //Hardcoded Patra Inner Eye offsets
3610 85 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3611 //Broken 'Big enemy' animation style
3612 85 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3613 //Broken Attribute 31/32
3614 85 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3615 85 }
3616
3617
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 10) //Shared candle use limits
3618 85 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3619
3620
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 11) //No cross-screen return points
3621 85 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3622
3623
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 12)
3624 {
3625 //Old fire trail duration
3626 85 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3627 //Old Intro String in Ganon Room Behavior
3628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3629 85 else set_bit(quest_rules,qr_GANONINTRO,1);
3630 85 }
3631
3632
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
114 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3633 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3634
3635
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 14) //Old Bridge Combo Behavior
3636 85 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3637
3638
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 15) //Broken Z3 Animation
3639 85 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3640
3641
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3642 85 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3643
3644
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 17)
3645 {
3646 //Old Quake/DrawYOffset behavior
3647 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3648 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3649 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3650 85 }
3651
3652
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 18)
3653 {
3654 //Broken DrawScreen Derivative Functions
3655 85 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3656 //Scrolling Cancels Charge
3657 85 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3658 85 }
3659
3660
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3661 85 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3662
3663
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 20)
3664 85 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3665
3666
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 21)
3667 {
3668 85 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3669 85 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3670 85 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3671 85 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3672 85 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3673 85 }
3674
3675
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 22)
3676 85 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3677
3678
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 23)
3679 85 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3680
3681
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 24)
3682 {
3683 85 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3684 85 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3685 85 }
3686
3687
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 25)
3688 {
3689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3690 85 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3691 85 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3692 85 }
3693
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 26)
3694 {
3695 85 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3696 85 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3697 85 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3698 85 }
3699
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3700 {
3701
2/2
✓ Branch 0 taken 25585 times.
✓ Branch 1 taken 85 times.
25670 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3702 25585 set_bit(quest_rules,q,0);
3703
2/2
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 85 times.
9605 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3704 9520 set_bit(quest_rules,q,0);
3705 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3706 85 }
3707
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 28)
3708 87 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3709
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 29)
3710 87 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3711
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 30)
3712 {
3713 87 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3714 87 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3715 87 }
3716
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 31)
3717 {
3718 87 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3719 87 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3720 87 }
3721
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 32)
3722 87 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3723
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 33)
3724 87 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3725
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 34)
3726 {
3727 87 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3728 87 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3729 87 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3730 87 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3731 87 }
3732
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 88 times.
114 if(compatrule_version < 35)
3733 {
3734 // Leaving this commented for now, might need to enable later -Em
3735 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3736 88 }
3737
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 88 times.
114 if(compatrule_version < 36)
3738 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3739
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 37)
3740 91 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3741
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 38)
3742 91 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3743
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 39)
3744 91 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3745
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 40)
3746 91 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3747
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 92 times.
114 if(compatrule_version < 41)
3748 92 set_bit(quest_rules,qr_BROKENHITBY,1);
3749
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 92 times.
114 if(compatrule_version < 42)
3750 92 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3751
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 92 times.
114 if(compatrule_version < 43)
3752 92 set_bit(quest_rules,qr_OLD_BOMB_HITBOXES,1);
3753
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 92 times.
114 if(compatrule_version < 44)
3754 92 set_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME,1);
3755
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 103 times.
114 if(compatrule_version < 45)
3756 103 set_bit(quest_rules,qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3757
3758 114 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3759
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if (s_version < 16)
3760 85 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3761
3762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
3763 114 memcpy(Header, &tempheader, sizeof(tempheader));
3764
3765 114 return 0;
3766 114 }
3767
3768 947040 void init_msgstr(MsgStr *str)
3769 {
3770 947040 str->s = "";
3771 947040 str->s.shrink_to_fit();
3772 947040 str->nextstring=0;
3773 947040 str->tile=0;
3774 947040 str->cset=0;
3775 947040 str->trans=false;
3776 947040 str->font=font_zfont;
3777 947040 str->y=32;
3778 947040 str->sfx=18;
3779 947040 str->listpos=0;
3780 947040 str->x=24;
3781 947040 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3782 947040 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3783 947040 str->hspace=0;
3784 947040 str->vspace=0;
3785 947040 str->stringflags=0;
3786 947040 str->margins[up] = 8;
3787 947040 str->margins[down] = 0;
3788 947040 str->margins[left] = 8;
3789 947040 str->margins[right] = 0;
3790 947040 str->portrait_tile = 0;
3791 947040 str->portrait_cset = 0;
3792 947040 str->portrait_x = 0;
3793 947040 str->portrait_y = 0;
3794 947040 str->portrait_tw = 1;
3795 947040 str->portrait_th = 1;
3796 947040 str->shadow_type = 0;
3797 947040 str->shadow_color = 0;
3798 947040 str->drawlayer = 6;
3799 947040 }
3800
3801 114 void init_msgstrings(int32_t start, int32_t end)
3802 {
3803
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(end <= start || end-start > msg_strings_size)
3804 return;
3805
3806
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 114 times.
934002 for(int32_t i=start; i<end; i++)
3807 {
3808 933888 init_msgstr(&MsgStrings[i]);
3809 933888 MsgStrings[i].listpos=i;
3810 933888 }
3811
3812
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(start==0)
3813 {
3814 114 MsgStrings[0].s = "(None)";
3815 114 MsgStrings[0].listpos = 0;
3816 114 }
3817 114 }
3818
3819 114 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3820 {
3821 114 MsgStr tempMsgString;
3822
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 init_msgstr(&tempMsgString);
3823
3824 114 word temp_msg_count=0;
3825 word temp_expansion[16];
3826 114 memset(temp_expansion, 0, 16*sizeof(word));
3827 114 char buf[8193] = {0};
3828
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version < 0x193)
3829 {
3830 byte tempbyte;
3831 4 int32_t strings_to_read=0;
3832
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3833
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3834 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3835 {
3836 4 strings_to_read=128;
3837 4 temp_msg_count=Header->old_str_count;
3838
3839 // Some sort of string count corruption seems to be common in old quests
3840
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3841 {
3842 temp_msg_count=128;
3843 }
3844 4 }
3845 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3846 {
3847 strings_to_read=255;
3848 temp_msg_count=Header->old_str_count;
3849 }
3850 else
3851 {
3852 if(!p_igetw(&temp_msg_count,f,true))
3853 {
3854 return qe_invalid;
3855 }
3856
3857 strings_to_read=temp_msg_count;
3858
3859 if(temp_msg_count >= msg_strings_size)
3860 {
3861 Z_message("Reallocating string buffer...\n");
3862
3863 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3864 // return qe_nomem;
3865
3866 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3867 delete[] MsgStrings;
3868 MsgStrings = new MsgStr[MAXMSGS];
3869 msg_strings_size = MAXMSGS;
3870 for(auto q = 0; q < msg_strings_size; ++q)
3871 {
3872 MsgStrings[q].clear();
3873 }
3874 }
3875 }
3876
3877 //reset the message strings
3878
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3879 {
3880
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3881 4 }
3882
3883
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3884 {
3885
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3886
3887
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3888 {
3889 return qe_invalid;
3890 }
3891
3892 512 buf[74] = '\0';
3893
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3894
3895
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3896 {
3897 return qe_invalid;
3898 }
3899
3900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3901 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3902 {
3903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3904
3905
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3906 {
3907 return qe_invalid;
3908 }
3909
3910
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3911 {
3912 return qe_invalid;
3913 }
3914 512 }
3915 else
3916 {
3917 if(!p_igetw(&tempMsgString.nextstring,f,true))
3918 {
3919 return qe_invalid;
3920 }
3921
3922 if(!pfread(temp_expansion,32,f,true))
3923 {
3924 return qe_invalid;
3925 }
3926 }
3927
3928
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3929 {
3930
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3931 512 }
3932 512 }
3933 4 }
3934 else
3935 {
3936 int32_t dummy_int;
3937 word s_version;
3938 word s_cversion;
3939
3940 //section version info
3941
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_version,f,true))
3942 {
3943 return qe_invalid;
3944 }
3945
3946 110 FFCore.quest_format[vStrings] = s_version;
3947
3948
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_cversion,f,true))
3949 {
3950 return qe_invalid;
3951 }
3952
3953 //al_trace("Strings version %d\n", s_version);
3954 //section size
3955
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy_int,f,true))
3956 {
3957 return qe_invalid;
3958 }
3959
3960 //finally... section data
3961
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&temp_msg_count,f,true))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(temp_msg_count >= msg_strings_size)
3967 {
3968 Z_message("Reallocating string buffer...\n");
3969
3970 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3971 // return qe_nomem;
3972 delete[] MsgStrings;
3973 MsgStrings = new MsgStr[MAXMSGS];
3974 msg_strings_size = MAXMSGS;
3975 for(auto q = 0; q < msg_strings_size; ++q)
3976 {
3977 MsgStrings[q].clear();
3978 }
3979 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3980 }
3981
3982 //reset the message strings
3983
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(keepdata)
3984 {
3985
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version < 7)
3986
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3987
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 init_msgstrings(0,msg_strings_size);
3988 110 }
3989
3990 110 int32_t string_length=(s_version<2)?73:145;
3991
3992
2/2
✓ Branch 0 taken 12526 times.
✓ Branch 1 taken 110 times.
12636 for(int32_t i=0; i<temp_msg_count; i++)
3993 {
3994
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 init_msgstr(&tempMsgString);
3995
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 11648 times.
12526 if(s_version > 8)
3996 {
3997
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&string_length,f,true))
3998 {
3999 return qe_invalid;
4000 }
4001 878 }
4002
2/2
✓ Branch 0 taken 12388 times.
✓ Branch 1 taken 138 times.
12526 if (string_length > 0)
4003 {
4004
2/4
✓ Branch 0 taken 12388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12388 times.
✗ Branch 3 not taken.
12388 if (!pfread(buf, string_length, f, true))
4005 {
4006 return qe_invalid;
4007 }
4008 12388 }
4009 else
4010 {
4011 138 buf[0] = 0;
4012 }
4013
4014
2/4
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12526 times.
✗ Branch 3 not taken.
12526 if(!p_igetw(&tempMsgString.nextstring,f,true))
4015 {
4016 return qe_invalid;
4017 }
4018
4019
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7880 times.
12526 if(s_version<2)
4020 {
4021 4646 buf[72] = '\0';
4022
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
4023 4646 }
4024 else
4025 {
4026 // June 2008: A bug corrupted the last 4 chars of a string.
4027 // Discard these.
4028
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(s_version<3)
4029 {
4030 for(int32_t j=140; j<144; j++)
4031 {
4032 buf[j] = '\0';
4033 }
4034 }
4035
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(string_length > 8192) string_length = 8192;
4036 7880 buf[string_length]='\0'; //Force-terminate
4037
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 tempMsgString.s = buf;
4038
4039
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 7002 times.
7880 if ( s_version >= 6 )
4040 {
4041
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&tempMsgString.tile,f,true))
4042 {
4043 return qe_invalid;
4044 }
4045 878 }
4046 else
4047 {
4048
2/4
✓ Branch 0 taken 7002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
7002 if(!p_igetw(&tempMsgString.tile,f,true))
4049 {
4050 return qe_invalid;
4051 }
4052 }
4053
4054
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.cset,f,true))
4055 {
4056 return qe_invalid;
4057 }
4058
4059 byte dummy_char;
4060
4061
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4062 {
4063 return qe_invalid;
4064 }
4065
4066 7880 tempMsgString.trans=dummy_char!=0;
4067
4068
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.font,f,true))
4069 {
4070 return qe_invalid;
4071 }
4072
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7880 times.
7880 if(s_version < 5)
4074 {
4075 if(!p_getc(&tempMsgString.y,f,true))
4076 {
4077 return qe_invalid;
4078 }
4079 }
4080 else
4081 {
4082
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.x,f,true))
4083 {
4084 return qe_invalid;
4085 }
4086
4087
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.y,f,true))
4088 {
4089 return qe_invalid;
4090 }
4091
4092
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.w,f,true))
4093 {
4094 return qe_invalid;
4095 }
4096
4097
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.h,f,true))
4098 {
4099 return qe_invalid;
4100 }
4101
4102
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.hspace,f,true))
4103 {
4104 return qe_invalid;
4105 }
4106
4107
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.vspace,f,true))
4108 {
4109 return qe_invalid;
4110 }
4111
4112
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.stringflags,f,true))
4113 {
4114 return qe_invalid;
4115 }
4116 }
4117
4118
2/2
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 878 times.
7880 if(s_version >= 7)
4119 {
4120
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 3512 times.
4390 for(int32_t q = 0; q < 4; ++q)
4121 {
4122
2/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3512 times.
✗ Branch 3 not taken.
3512 if(!p_getc(&tempMsgString.margins[q],f,true))
4123 {
4124 return qe_invalid;
4125 }
4126 3512 }
4127
4128
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4129 {
4130 return qe_invalid;
4131 }
4132
4133
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4134 {
4135 return qe_invalid;
4136 }
4137
4138
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_x,f,true))
4139 {
4140 return qe_invalid;
4141 }
4142
4143
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_y,f,true))
4144 {
4145 return qe_invalid;
4146 }
4147
4148
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4149 {
4150 return qe_invalid;
4151 }
4152
4153
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_th,f,true))
4154 {
4155 return qe_invalid;
4156 }
4157 878 }
4158
4159
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 7002 times.
7880 if(s_version >= 8)
4160 {
4161
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.shadow_type,f,true))
4162 {
4163 return qe_invalid;
4164 }
4165
4166
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.shadow_color,f,true))
4167 {
4168 return qe_invalid;
4169 }
4170 878 }
4171
4172
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 7119 times.
7880 if(s_version >= 10)
4173 {
4174
2/4
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✗ Branch 3 not taken.
761 if(!p_getc(&tempMsgString.drawlayer,f,true))
4175 {
4176 return qe_invalid;
4177 }
4178 761 }
4179
4180
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.sfx,f,true))
4181 {
4182 return qe_invalid;
4183 }
4184
4185
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(s_version>3)
4186 {
4187
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.listpos,f,true))
4188 {
4189 return qe_invalid;
4190 }
4191 7880 }
4192 }
4193
4194
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 if(keepdata==true)
4195 {
4196
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 MsgStrings[i].copyAll(tempMsgString);
4197 12526 }
4198 12526 }
4199 }
4200
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
4202 {
4203 114 msg_count=temp_msg_count;
4204 114 }
4205
4206 114 return 0;
4207 114 }
4208
4209 114 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4210 {
4211
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4213 {
4214 4 return 0;
4215 }
4216
4217 110 word temp_door_combo_set_count=0;
4218 DoorComboSet tempDoorComboSet;
4219 word dummy_word;
4220 int32_t dummy_long;
4221 byte padding;
4222 110 int32_t s_version = 0;
4223
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
4225 {
4226
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 110 times.
28270 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4227 {
4228 28160 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4229 28160 }
4230 110 }
4231
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Header->zelda_version > 0x192)
4233 {
4234 //section version info
4235
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
4236 {
4237 return qe_invalid;
4238 }
4239
4240 110 FFCore.quest_format[vDoors] = s_version;
4241
4242 //al_trace("Door combo sets version %d\n", dummy_word);
4243
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy_word,f,true))
4244 {
4245 return qe_invalid;
4246 }
4247
4248 //section size
4249
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy_long,f,true))
4250 {
4251 return qe_invalid;
4252 }
4253 110 }
4254
4255 //finally... section data
4256
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&temp_door_combo_set_count,f,true))
4257 {
4258 return qe_invalid;
4259 }
4260
4261
2/2
✓ Branch 0 taken 846 times.
✓ Branch 1 taken 110 times.
956 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4262 {
4263 846 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4264
4265 //name
4266
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4267 {
4268 return qe_invalid;
4269 }
4270
4271
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4272 {
4273 if(!p_getc(&padding,f,true))
4274 {
4275 return qe_invalid;
4276 }
4277 }
4278
4279 //up door
4280
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4281 {
4282
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4283 {
4284
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4285 {
4286 return qe_invalid;
4287 }
4288 30456 }
4289 7614 }
4290
4291
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4292 {
4293
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4294 {
4295
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4296 {
4297 return qe_invalid;
4298 }
4299 30456 }
4300 7614 }
4301
4302 //down door
4303
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4304 {
4305
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4306 {
4307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30456 times.
30456 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4308 {
4309 return qe_invalid;
4310 }
4311 30456 }
4312 7614 }
4313
4314
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4315 {
4316
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4317 {
4318
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4319 {
4320 return qe_invalid;
4321 }
4322 30456 }
4323 7614 }
4324
4325 //left door
4326
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4327 {
4328
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4329 {
4330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45684 times.
45684 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4331 {
4332 return qe_invalid;
4333 }
4334 45684 }
4335 7614 }
4336
4337
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4338 {
4339
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4340 {
4341
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4342 {
4343 return qe_invalid;
4344 }
4345 45684 }
4346 7614 }
4347
4348 //right door
4349
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4350 {
4351
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4352 {
4353
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4354 {
4355 return qe_invalid;
4356 }
4357 45684 }
4358 7614 }
4359
4360
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4361 {
4362
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4363 {
4364
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4365 {
4366 return qe_invalid;
4367 }
4368 45684 }
4369 7614 }
4370
4371 //up bomb rubble
4372
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4373 {
4374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4375 {
4376 return qe_invalid;
4377 }
4378 1692 }
4379
4380
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4381 {
4382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4383 {
4384 return qe_invalid;
4385 }
4386 1692 }
4387
4388 //down bomb rubble
4389
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4390 {
4391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4392 {
4393 return qe_invalid;
4394 }
4395 1692 }
4396
4397
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4398 {
4399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4400 {
4401 return qe_invalid;
4402 }
4403 1692 }
4404
4405 //left bomb rubble
4406
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4407 {
4408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4409 {
4410 return qe_invalid;
4411 }
4412 2538 }
4413
4414
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4415 {
4416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4417 {
4418 return qe_invalid;
4419 }
4420 2538 }
4421
4422
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4423 {
4424 if(!p_getc(&padding,f,true))
4425 {
4426 return qe_invalid;
4427 }
4428
4429 }
4430
4431 //right bomb rubble
4432
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4433 {
4434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4435 {
4436 return qe_invalid;
4437 }
4438 2538 }
4439
4440
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4441 {
4442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4443 {
4444 return qe_invalid;
4445 }
4446 2538 }
4447
4448
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4449 {
4450 if(!p_getc(&padding,f,true))
4451 {
4452 return qe_invalid;
4453 }
4454 }
4455
4456 //walkthrough stuff
4457
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 846 times.
4230 for(int32_t j=0; j<4; j++)
4458 {
4459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3384 times.
3384 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4460 {
4461 return qe_invalid;
4462 }
4463 3384 }
4464
4465
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 846 times.
4230 for(int32_t j=0; j<4; j++)
4466 {
4467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3384 times.
3384 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4468 {
4469 return qe_invalid;
4470 }
4471 3384 }
4472
4473 //flags
4474
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4475 {
4476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4477 {
4478 return qe_invalid;
4479 }
4480 1692 }
4481
4482
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4483 {
4484 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4485 {
4486 return qe_invalid;
4487 }
4488 }
4489
4490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 846 times.
846 if(keepdata==true)
4491 {
4492 846 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4493 846 }
4494 846 }
4495
4496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
4497 {
4498 110 door_combo_set_count=temp_door_combo_set_count;
4499 110 }
4500
4501 110 return 0;
4502 114 }
4503
4504 int32_t count_dmaps()
4505 {
4506 int32_t i=MAXDMAPS-1;
4507 bool found=false;
4508
4509 while(i>=0 && !found)
4510 {
4511 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4512 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4513 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4514 found=true;
4515
4516 for(int32_t j=0; j<8; j++)
4517 {
4518 if(DMaps[i].grid[j]!=0)
4519
4520 found=true;
4521 }
4522
4523 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4524 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4525 found=true;
4526
4527 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4528 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4529 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4530 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4531 found=true;
4532
4533 if(!found)
4534 {
4535 i--;
4536 }
4537 }
4538
4539 return i+1;
4540 }
4541
4542
4543 int32_t count_shops(miscQdata *Misc)
4544 {
4545 int32_t i=255,j;
4546 bool found=false;
4547
4548 while(i>=0 && !found)
4549 {
4550 j=2;
4551
4552 while(j>=0 && !found)
4553 {
4554 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4555 {
4556 found=true;
4557 }
4558 else
4559 {
4560 j--;
4561 }
4562 }
4563
4564 if(Misc->shop[i].name[0]!=0)
4565 {
4566 found=true;
4567 }
4568
4569 if(!found)
4570 {
4571 i--;
4572 }
4573 }
4574
4575 return i+1;
4576 }
4577
4578 int32_t count_infos(miscQdata *Misc)
4579 {
4580 int32_t i=255,j;
4581 bool found=false;
4582
4583 while(i>=0 && !found)
4584 {
4585 j=2;
4586
4587 while(j>=0 && !found)
4588 {
4589 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4590 {
4591 found=true;
4592 }
4593 else
4594 {
4595 j--;
4596 }
4597 }
4598
4599 if(Misc->info[i].name[0]!=0)
4600 {
4601 found=true;
4602 }
4603
4604 if(!found)
4605 {
4606 i--;
4607 }
4608 }
4609
4610 return i+1;
4611 }
4612
4613 int32_t count_warprings(miscQdata *Misc)
4614 {
4615 int32_t i=15,j;
4616 bool found=false;
4617
4618 while(i>=0 && !found)
4619 {
4620 j=7;
4621
4622 while(j>=0 && !found)
4623 {
4624 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4625 {
4626 found=true;
4627 }
4628 else
4629 {
4630 j--;
4631 }
4632 }
4633
4634 if(!found)
4635 {
4636 i--;
4637 }
4638 }
4639
4640 return i+1;
4641 }
4642
4643 int32_t count_palcycles(miscQdata *Misc)
4644 {
4645 int32_t i=255,j;
4646 bool found=false;
4647
4648 while(i>=0 && !found)
4649 {
4650 j=2;
4651
4652 while(j>=0 && !found)
4653 {
4654 if(Misc->cycles[i][j].count!=0)
4655 {
4656 found=true;
4657 }
4658 else
4659 {
4660 j--;
4661 }
4662 }
4663
4664 if(!found)
4665 {
4666 i--;
4667 }
4668 }
4669
4670 return i+1;
4671 }
4672
4673 203362 void clear_screen(mapscr *temp_scr)
4674 {
4675 203362 temp_scr->zero_memory();
4676 203362 }
4677
4678 114 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4679 {
4680 114 word dmapstoread=0;
4681 dmap tempDMap;
4682
4683 int32_t dummy;
4684 114 word s_version=0, s_cversion=0;
4685 byte padding;
4686
4687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
4688 {
4689
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<max_dmaps; i++)
4690 {
4691 58368 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4692 58368 sprintf(DMaps[start_dmap+i].title," ");
4693 58368 sprintf(DMaps[start_dmap+i].intro," ");
4694 58368 DMaps[start_dmap+i].type |= dmCAVE;
4695 58368 }
4696 114 }
4697
4698
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 4 times.
114 if(!Header || Header->zelda_version > 0x192)
4699 {
4700 //section version info
4701
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
4702 {
4703 return qe_invalid;
4704 }
4705
4706 110 FFCore.quest_format[vDMaps] = s_version;
4707
4708 //al_trace("DMaps version %d\n", s_version);
4709
4710
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
4711 {
4712 return qe_invalid;
4713 }
4714
4715 //section size
4716
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
4717 {
4718 return qe_invalid;
4719 }
4720
4721 //finally... section data
4722
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dmapstoread,f,true))
4723 {
4724 return qe_invalid;
4725 }
4726 110 }
4727 else
4728 {
4729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4730 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4731 {
4732 4 dmapstoread=32;
4733 4 }
4734 else if(s_version <= 4)
4735 {
4736 dmapstoread=OLDMAXDMAPS;
4737 }
4738 else
4739 {
4740 dmapstoread=MAXDMAPS;
4741 }
4742 }
4743
4744
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 dmapstoread=zc_min(dmapstoread, max_dmaps);
4745
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4746
4747
2/2
✓ Branch 0 taken 55168 times.
✓ Branch 1 taken 114 times.
55282 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4748 {
4749 55168 memset(&tempDMap,0,sizeof(dmap));
4750 55168 sprintf(tempDMap.title," ");
4751 55168 sprintf(tempDMap.intro," ");
4752
4753
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.map,f,keepdata))
4754 {
4755 return qe_invalid;
4756 }
4757
4758
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version <= 4)
4759 {
4760 byte tempbyte;
4761
4762
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4763 {
4764 return qe_invalid;
4765 }
4766
4767 1408 tempDMap.level=(word)tempbyte;
4768 1408 }
4769 else
4770 {
4771
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempDMap.level,f,keepdata))
4772 {
4773 return qe_invalid;
4774 }
4775 }
4776
4777
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.xoff,f,keepdata))
4778 {
4779 return qe_invalid;
4780 }
4781
4782
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.compass,f,keepdata))
4783 {
4784 return qe_invalid;
4785 }
4786
4787
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version > 8) // February 2009
4788 {
4789
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempDMap.color,f,true))
4790 {
4791 return qe_invalid;
4792 }
4793 53760 }
4794 else
4795 {
4796 byte tempbyte;
4797
4798
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4799 {
4800 return qe_invalid;
4801 }
4802
4803 1408 tempDMap.color = (word)tempbyte;
4804 }
4805
4806
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.midi,f,keepdata))
4807 {
4808 return qe_invalid;
4809 }
4810
4811
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.cont,f,keepdata))
4812 {
4813 return qe_invalid;
4814 }
4815
4816
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.type,f,keepdata))
4817 {
4818 return qe_invalid;
4819 }
4820
4821
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 54466 times.
✓ Branch 2 taken 690 times.
✓ Branch 3 taken 12 times.
55870 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4822
1/2
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
702 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4823 690 tempDMap.xoff = 0;
4824
4825
2/2
✓ Branch 0 taken 441344 times.
✓ Branch 1 taken 55168 times.
496512 for(int32_t j=0; j<8; j++)
4826 {
4827
1/2
✓ Branch 0 taken 441344 times.
✗ Branch 1 not taken.
441344 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4828 {
4829 return qe_invalid;
4830 }
4831 441344 }
4832
4833
4/8
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55040 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55168 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4834 {
4835
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4836 {
4837 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4838 38 }
4839
4840
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4841 {
4842 4 tempDMap.cont-=tempDMap.xoff;
4843 4 tempDMap.compass-=tempDMap.xoff;
4844 4 }
4845
4846 //forgotten -DD
4847
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4848 {
4849 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4850 90 }
4851 128 }
4852 else
4853 {
4854
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4855 {
4856 return qe_invalid;
4857 }
4858
4859
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4860 {
4861 return qe_invalid;
4862 }
4863
4864
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4865 {
4866 return qe_invalid;
4867 }
4868
4869
3/8
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 55040 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55040 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4870 {
4871 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4872 if(keepdata==true)
4873 {
4874 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4875 }
4876
4877 continue;
4878 }
4879
4880
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4881 {
4882 if(!p_getc(&padding,f,keepdata))
4883 {
4884 return qe_invalid;
4885 }
4886 }
4887
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4888 {
4889
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4890 {
4891 return qe_invalid;
4892 }
4893 14848 }
4894 else
4895 {
4896
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4897 {
4898 return qe_invalid;
4899 }
4900 }
4901
4902
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4903 {
4904 return qe_invalid;
4905 }
4906
4907
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4908 {
4909 if(!p_getc(&padding,f,keepdata))
4910 {
4911 return qe_invalid;
4912 }
4913 }
4914
4915
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4916 {
4917
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4918 {
4919 return qe_invalid;
4920 }
4921 14848 }
4922 else
4923 {
4924
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4925 {
4926 return qe_invalid;
4927 }
4928 }
4929
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4930 {
4931 return qe_invalid;
4932 }
4933
4934
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4935 {
4936 if(!p_getc(&padding,f,keepdata))
4937 {
4938 return qe_invalid;
4939 }
4940 }
4941
4942
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4943 {
4944
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4945 {
4946 return qe_invalid;
4947 }
4948 14848 }
4949 else
4950 {
4951
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4952 {
4953 return qe_invalid;
4954 }
4955 }
4956
4957
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4958 {
4959 return qe_invalid;
4960 }
4961
4962
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4963 {
4964
4965 if(!p_getc(&padding,f,keepdata))
4966 {
4967 return qe_invalid;
4968 }
4969 }
4970
4971
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4972 {
4973
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4974 {
4975 return qe_invalid;
4976 }
4977 14848 }
4978 else
4979 {
4980
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4981 {
4982 return qe_invalid;
4983 }
4984 }
4985
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989
4990
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4991 {
4992 return qe_invalid;
4993 }
4994 }
4995
4996
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version>1)
4997 {
4998
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4999 {
5000 return qe_invalid;
5001 }
5002
5003
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
5004 {
5005 return qe_invalid;
5006 }
5007
5008
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
5009 {
5010 return qe_invalid;
5011 }
5012 53760 }
5013
5014
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version>2)
5015 {
5016 byte di[32];
5017
5018
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!pfread(&di, 32, f, true)) return qe_invalid;
5019
5020
2/2
✓ Branch 0 taken 13762560 times.
✓ Branch 1 taken 53760 times.
13816320 for(int32_t j=0; j<MAXITEMS; j++)
5021 {
5022
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13762553 times.
13762560 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5023 13762553 else tempDMap.disableditems[j]=0;
5024 13762560 }
5025 53760 }
5026
5027
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version >= 6)
5028 {
5029
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempDMap.flags,f,keepdata))
5030 {
5031 return qe_invalid;
5032 }
5033 53760 }
5034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
5035 {
5036 char temp;
5037
5038 if(!p_getc(&temp,f,keepdata))
5039 {
5040 return qe_invalid;
5041 }
5042
5043 tempDMap.flags = temp;
5044 }
5045
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5046 {
5047 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5048 697 }
5049 else
5050 711 tempDMap.flags=0;
5051
5052
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version<7)
5053 {
5054
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5055 697 tempDMap.flags|= dmfVIEWMAP;
5056 1408 }
5057
5058
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version<8)
5059 {
5060
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5061 {
5062 609 tempDMap.type &= ~dmDNGN;
5063 609 tempDMap.type |= dmCAVE;
5064 609 }
5065
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5066 {
5067 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5068 469 }
5069 1408 }
5070
5071
5/8
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 55040 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 55040 times.
✗ Branch 7 not taken.
55168 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5072 55040 && (Header->zelda_version < 0x193))
5073 {
5074 if(!p_getc(&padding,f,keepdata))
5075 {
5076 return qe_invalid;
5077 }
5078 }
5079
5080
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 10)
5081 {
5082
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempDMap.sideview,f,keepdata))
5083 {
5084 return qe_invalid;
5085 }
5086 14848 }
5087
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version < 10) tempDMap.sideview = 0;
5088
5089 //Dmap Scripts
5090
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 12)
5091 {
5092
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.script,f,keepdata))
5093 {
5094 return qe_invalid;
5095 }
5096
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
5097 {
5098
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5099 {
5100 return qe_invalid;
5101 }
5102 118784 }
5103 14848 }
5104
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if ( s_version < 12 )
5105 {
5106 40320 tempDMap.script = 0;
5107
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5108 {
5109 322560 tempDMap.initD[q] = 0;
5110 322560 }
5111 40320 }
5112
5113
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 13)
5114 {
5115
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
5116 {
5117
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
5118 {
5119
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5120 {
5121 return qe_invalid;
5122 }
5123 7720960 }
5124 118784 }
5125 14848 }
5126
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if ( s_version < 13 )
5127 {
5128 40320 tempDMap.script = 0;
5129
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5130 {
5131
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for ( int32_t w = 0; w < 65; w++ )
5132 20966400 tempDMap.initD_label[q][w] = 0;
5133 322560 }
5134 40320 }
5135
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 14)
5136 {
5137
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5138 {
5139 return qe_invalid;
5140 }
5141
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5142 {
5143 return qe_invalid;
5144 }
5145
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; ++q )
5146 {
5147
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5148 {
5149 return qe_invalid;
5150 }
5151 118784 }
5152
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t q = 0; q < 8; ++q)
5153 {
5154
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; ++w )
5155 {
5156
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5157 {
5158 return qe_invalid;
5159 }
5160 7720960 }
5161 118784 }
5162 14848 }
5163 else
5164 {
5165 40320 tempDMap.active_sub_script = 0;
5166 40320 tempDMap.passive_sub_script = 0;
5167
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5168 {
5169 322560 tempDMap.sub_initD[q] = 0;
5170
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5171 20966400 tempDMap.sub_initD_label[q][w] = 0;
5172 322560 }
5173 }
5174
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 15)
5175 {
5176
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5177 {
5178 return qe_invalid;
5179 }
5180
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; ++q )
5181 {
5182
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5183 {
5184 return qe_invalid;
5185 }
5186 118784 }
5187
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t q = 0; q < 8; ++q)
5188 {
5189
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; ++w )
5190 {
5191
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5192 {
5193 return qe_invalid;
5194 }
5195 7720960 }
5196 118784 }
5197 14848 }
5198 else
5199 {
5200 40320 tempDMap.onmap_script = 0;
5201
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5202 {
5203 322560 tempDMap.onmap_initD[q] = 0;
5204
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5205 {
5206 20966400 tempDMap.onmap_initD_label[q][w] = 0;
5207 20966400 }
5208 322560 }
5209 }
5210
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 16)
5211 {
5212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5213 {
5214 return qe_invalid;
5215 }
5216 14848 }
5217 else
5218 {
5219 40320 tempDMap.mirrorDMap = -1;
5220 }
5221
5222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55168 times.
55168 if(keepdata==true)
5223 {
5224 55168 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5225 55168 }
5226 55168 }
5227
5228 114 return 0;
5229 114 }
5230
5231 105 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5232 {
5233 //these are here to bypass compiler warnings about unused arguments
5234 105 Header=Header;
5235
5236 miscQdata temp_misc;
5237 105 word s_version=0, s_cversion=0;
5238 105 int32_t tempsize=0;
5239 word dummyw;
5240
5241 105 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5242
5243 //section version info
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
5245 {
5246 return qe_invalid;
5247 }
5248
5249 105 FFCore.quest_format[vColours] = s_version;
5250
5251 105 al_trace("Misc Colours section version: %d\n", s_version);
5252
5253 //al_trace("Misc. colors version %d\n", s_version);
5254
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
5260 //section size
5261
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tempsize,f,true))
5262 {
5263 return qe_invalid;
5264 }
5265
5266 //finally... section data
5267 105 readsize=0;
5268
5269
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.text,f,true))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.caption,f,true))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5285 {
5286 return qe_invalid;
5287 }
5288
5289
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5300 {
5301 return qe_invalid;
5302 }
5303
5304
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5305 {
5306 return qe_invalid;
5307 }
5308
5309
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5310 {
5311 return qe_invalid;
5312 }
5313
5314
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5315 {
5316 return qe_invalid;
5317 }
5318
5319
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5320 {
5321 return qe_invalid;
5322 }
5323
5324
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5325 {
5326 return qe_invalid;
5327 }
5328
5329
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5330 {
5331 return qe_invalid;
5332 }
5333
5334
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5335 {
5336 return qe_invalid;
5337 }
5338
5339
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5340 {
5341 return qe_invalid;
5342 }
5343
5344
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5345 {
5346 return qe_invalid;
5347 }
5348
5349
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5355 {
5356 return qe_invalid;
5357 }
5358
5359
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5365 {
5366 return qe_invalid;
5367 }
5368
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version < 4)
5369 {
5370
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5371 return qe_invalid;
5372 76 temp_misc.colors.triforce_tile = dummyw;
5373
5374
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5375 return qe_invalid;
5376 76 temp_misc.colors.triframe_tile = dummyw;
5377
5378
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5379 return qe_invalid;
5380 76 temp_misc.colors.overworld_map_tile = dummyw;
5381
5382
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5383 return qe_invalid;
5384 76 temp_misc.colors.dungeon_map_tile = dummyw;
5385
5386
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5387 return qe_invalid;
5388 76 temp_misc.colors.blueframe_tile = dummyw;
5389
5390
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5391 return qe_invalid;
5392 76 temp_misc.colors.HCpieces_tile = dummyw;
5393 76 }
5394
5395
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5396 {
5397 return qe_invalid;
5398 }
5399
5400
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5401 {
5402 return qe_invalid;
5403 }
5404
5405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version < 2)
5406 {
5407 temp_misc.colors.msgtext = 0x01;
5408 }
5409 else
5410 {
5411
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5412 {
5413 return qe_invalid;
5414 }
5415 }
5416
5417
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if ( s_version >= 3 ) //expanded tile pages to 825
5418 {
5419
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5420 {
5421 return qe_invalid;
5422 }
5423
5424
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5425 {
5426 return qe_invalid;
5427 }
5428
5429
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5430 {
5431 return qe_invalid;
5432 }
5433
5434
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5435 {
5436 return qe_invalid;
5437 }
5438
5439
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5440 {
5441 return qe_invalid;
5442 }
5443
5444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5445 {
5446 return qe_invalid;
5447 }
5448 29 }
5449
5450
5451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
5452 {
5453 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5454 105 }
5455
5456 105 return 0;
5457 105 }
5458
5459 105 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5460 {
5461 miscQdata temp_misc;
5462 105 word s_version=0, s_cversion=0;
5463 byte icons;
5464 105 int32_t tempsize=0;
5465
5466 105 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5467
5468 //section version info
5469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
5470 {
5471 return qe_invalid;
5472 }
5473
5474 105 FFCore.quest_format[vIcons] = s_version;
5475
5476 //al_trace("Game icons version %d\n", s_version);
5477
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
5478 {
5479 return qe_invalid;
5480 }
5481
5482
5483 //section size
5484
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tempsize,f,true))
5485 {
5486 return qe_invalid;
5487 }
5488
5489 //finally... section data
5490 105 readsize=0;
5491
5492 105 icons=4;
5493
5494
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( s_version >= 10 )
5495 {
5496
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<icons; i++)
5497 {
5498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&temp_misc.icons[i],f,true))
5499 {
5500 return qe_invalid;
5501 }
5502 116 }
5503 29 }
5504 else
5505 {
5506
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<icons; i++)
5507 {
5508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_igetw(&temp_misc.icons[i],f,true))
5509 {
5510 return qe_invalid;
5511 }
5512 304 }
5513 }
5514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
5515 {
5516 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5517 105 }
5518
5519 105 return 0;
5520 105 }
5521
5522 114 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5523 {
5524 114 word maxinfos=256;
5525 114 word maxshops=256;
5526 114 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5527 114 word ponds=16, pondsize=72, expansionsize=98*2;
5528 byte tempbyte, padding;
5529 miscQdata temp_misc;
5530 114 word s_version=0, s_cversion=0;
5531 word swaptmp;
5532 114 int32_t tempsize=0;
5533
5534 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5535
5536
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxshops; ++i)
5537 {
5538 29184 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5539 29184 }
5540
5541
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxinfos; ++i)
5542 {
5543 29184 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5544 29184 }
5545
5546
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5547 {
5548 //section version info
5549
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
5550 {
5551 return qe_invalid;
5552 }
5553
5554 110 FFCore.quest_format[vMisc] = s_version;
5555
5556 //al_trace("Misc. data version %d\n", s_version);
5557
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
5558 {
5559 return qe_invalid;
5560 }
5561
5562
5563 //section size
5564
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&tempsize,f,true))
5565 {
5566 return qe_invalid;
5567 }
5568 110 }
5569
5570 //finally... section data
5571 114 readsize=0;
5572
5573 //shops
5574
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5575 {
5576
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&shops,f,true))
5577 {
5578 return qe_invalid;
5579 }
5580 110 }
5581
5582
2/2
✓ Branch 0 taken 1223 times.
✓ Branch 1 taken 114 times.
1337 for(int32_t i=0; i<shops; i++)
5583 {
5584
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1105 times.
1223 if(s_version > 6)
5585 {
5586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1105 times.
1105 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5587 {
5588 return qe_invalid;
5589 }
5590 1105 }
5591
5592
2/2
✓ Branch 0 taken 3669 times.
✓ Branch 1 taken 1223 times.
4892 for(int32_t j=0; j<3; j++)
5593 {
5594
1/2
✓ Branch 0 taken 3669 times.
✗ Branch 1 not taken.
3669 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5595 {
5596 return qe_invalid;
5597 }
5598
5599
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 354 times.
3669 if(s_version < 4)
5600 {
5601 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5602 354 }
5603 3669 }
5604
5605
2/2
✓ Branch 0 taken 1159 times.
✓ Branch 1 taken 64 times.
1223 if(Header->zelda_version < 0x193)
5606 {
5607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5608 {
5609 return qe_invalid;
5610 }
5611 64 }
5612
5613
2/2
✓ Branch 0 taken 3669 times.
✓ Branch 1 taken 1223 times.
4892 for(int32_t j=0; j<3; j++)
5614 {
5615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3669 times.
3669 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5616 {
5617 return qe_invalid;
5618 }
5619 3669 }
5620
5621
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1105 times.
1223 if(s_version > 3)
5622 {
5623
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 1105 times.
4420 for(int32_t j=0; j<3; j++)
5624 {
5625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3315 times.
3315 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5626 return qe_invalid;
5627 3315 }
5628 1105 }
5629
5630 /*
5631 if(s_version < 8)
5632 {
5633 for(int32_t j=0; j<3; j++)
5634 {
5635 (&temp_misc.shop[i].str[j])=0; //initialise.
5636 }
5637 }
5638 */
5639 1223 }
5640
5641 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5642
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxshops; ++i)
5643 {
5644
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<3-1; j++)
5645 {
5646
2/2
✓ Branch 0 taken 87552 times.
✓ Branch 1 taken 58368 times.
145920 for(int32_t k=0; k<2-j; k++)
5647 {
5648
2/2
✓ Branch 0 taken 2516 times.
✓ Branch 1 taken 85036 times.
87552 if(temp_misc.shop[i].hasitem[k]==0)
5649 {
5650 85036 swaptmp = temp_misc.shop[i].item[k];
5651 85036 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5652 85036 temp_misc.shop[i].item[k+1] = swaptmp;
5653 85036 swaptmp = temp_misc.shop[i].price[k];
5654 85036 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5655 85036 temp_misc.shop[i].price[k+1] = swaptmp;
5656 85036 swaptmp = temp_misc.shop[i].hasitem[k];
5657 85036 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5658 85036 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5659 85036 }
5660 87552 }
5661 58368 }
5662 29184 }
5663
5664 //infos
5665
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5666 {
5667
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&infos,f,true))
5668 {
5669 return qe_invalid;
5670 }
5671 110 }
5672
5673
2/2
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 114 times.
1732 for(int32_t i=0; i<infos; i++)
5674 {
5675
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1539 times.
1618 if(s_version > 6)
5676 {
5677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5678 {
5679 return qe_invalid;
5680 }
5681 1539 }
5682
5683
2/2
✓ Branch 0 taken 4854 times.
✓ Branch 1 taken 1618 times.
6472 for(int32_t j=0; j<3; j++)
5684 {
5685
2/4
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4854 if((Header->zelda_version < 0x192)||
5686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5687 {
5688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5689 {
5690 return qe_invalid;
5691 }
5692
5693 192 temp_misc.info[i].str[j]=tempbyte;
5694 192 }
5695 else
5696 {
5697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5698 {
5699 return qe_invalid;
5700 }
5701 }
5702 4854 }
5703
5704
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 64 times.
1618 if(Header->zelda_version < 0x193)
5705 {
5706
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5707 {
5708 return qe_invalid;
5709 }
5710 64 }
5711
5712
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1618 if((Header->zelda_version == 0x192)&&(Header->build>145))
5713 {
5714 if(!p_getc(&padding,f,true))
5715 {
5716 return qe_invalid;
5717 }
5718 }
5719
5720
2/2
✓ Branch 0 taken 4854 times.
✓ Branch 1 taken 1618 times.
6472 for(int32_t j=0; j<3; j++)
5721 {
5722
1/2
✓ Branch 0 taken 4854 times.
✗ Branch 1 not taken.
4854 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5723 {
5724 return qe_invalid;
5725 }
5726 4854 }
5727 1618 }
5728
5729 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5730
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxinfos; ++i)
5731 {
5732
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<3-1; j++)
5733 {
5734
2/2
✓ Branch 0 taken 87552 times.
✓ Branch 1 taken 58368 times.
145920 for(int32_t k=0; k<2-j; k++)
5735 {
5736
2/2
✓ Branch 0 taken 1887 times.
✓ Branch 1 taken 85665 times.
87552 if(temp_misc.info[i].str[k]==0)
5737 {
5738 85665 swaptmp = temp_misc.info[i].str[k];
5739 85665 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5740 85665 temp_misc.info[i].str[k+1] = swaptmp;
5741 85665 swaptmp = temp_misc.info[i].price[k];
5742 85665 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5743 85665 temp_misc.info[i].price[k+1] = swaptmp;
5744 85665 }
5745 87552 }
5746 58368 }
5747 29184 }
5748
5749
5750 //warp rings
5751
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version > 5)
5752 105 warprings++;
5753
5754
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5755 {
5756
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&warprings,f,true))
5757 {
5758 return qe_invalid;
5759 }
5760 110 }
5761
5762
2/2
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 114 times.
1226 for(int32_t i=0; i<warprings; i++)
5763 {
5764
2/2
✓ Branch 0 taken 9896 times.
✓ Branch 1 taken 1112 times.
11008 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5765 {
5766
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 9000 times.
9896 if(s_version <= 3)
5767 {
5768
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,true))
5769 {
5770 return qe_invalid;
5771 }
5772
5773 896 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5774 896 }
5775 else
5776 {
5777
1/2
✓ Branch 0 taken 9000 times.
✗ Branch 1 not taken.
9000 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5778 {
5779 return qe_invalid;
5780 }
5781 }
5782 9896 }
5783
5784
2/2
✓ Branch 0 taken 9896 times.
✓ Branch 1 taken 1112 times.
11008 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5785 {
5786
1/2
✓ Branch 0 taken 9896 times.
✗ Branch 1 not taken.
9896 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5787 {
5788 return qe_invalid;
5789 }
5790 9896 }
5791
5792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 if(!p_getc(&temp_misc.warp[i].size,f,true))
5793 {
5794 return qe_invalid;
5795 }
5796
5797
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 32 times.
1112 if(Header->zelda_version < 0x193)
5798 {
5799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5800 {
5801 return qe_invalid;
5802 }
5803 32 }
5804 1112 }
5805
5806 //palette cycles
5807
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5808 {
5809
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5810 {
5811
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5812 {
5813 3072 temp_misc.cycles[i][j].first=0;
5814 3072 temp_misc.cycles[i][j].count=0;
5815 3072 temp_misc.cycles[i][j].speed=0;
5816 3072 }
5817 1024 }
5818
5819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5820 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5821 {
5822 4 palcycles=16;
5823 4 }
5824
5825
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5826 {
5827
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5828 {
5829
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5830 {
5831 return qe_invalid;
5832 }
5833
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5835 {
5836 return qe_invalid;
5837 }
5838
5839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5840 {
5841 return qe_invalid;
5842 }
5843 192 }
5844 64 }
5845 4 }
5846
5847 //Wind warps are now just another warp ring.
5848
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version <= 5)
5849 {
5850
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5851 {
5852
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5853 {
5854 return qe_invalid;
5855 }
5856 5 }
5857
5858
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5859 {
5860
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5861 {
5862
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5863 {
5864 return qe_invalid;
5865 }
5866
5867 79 temp_misc.warp[8].dmap[i]=tempbyte;
5868 79 }
5869 else
5870 {
5871 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5872 {
5873 return qe_invalid;
5874 }
5875 }
5876
5877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5878 {
5879 return qe_invalid;
5880 }
5881
5882 79 temp_misc.warp[8].size = 9;
5883
5884
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5885 {
5886 if(!p_getc(&tempbyte,f,true))
5887 {
5888 return qe_invalid;
5889 }
5890 }
5891 79 }
5892 9 }
5893
5894
5895 //triforce pieces
5896
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<triforces; i++)
5897 {
5898
1/2
✓ Branch 0 taken 912 times.
✗ Branch 1 not taken.
912 if(!p_getc(&temp_misc.triforce[i],f,true))
5899 {
5900 return qe_invalid;
5901 }
5902 912 }
5903
5904 //misc color data
5905
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<3)
5906 {
5907
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5908 {
5909 return qe_invalid;
5910 }
5911
5912
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5913 {
5914 return qe_invalid;
5915 }
5916
5917
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5918 {
5919 return qe_invalid;
5920 }
5921
5922
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5923 {
5924 return qe_invalid;
5925 }
5926
5927
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5928 {
5929 return qe_invalid;
5930 }
5931
5932
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5933 {
5934 return qe_invalid;
5935 }
5936
5937
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5938 {
5939 return qe_invalid;
5940 }
5941
5942
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5943 {
5944 return qe_invalid;
5945 }
5946
5947
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5948 {
5949 return qe_invalid;
5950 }
5951
5952
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5953 {
5954 return qe_invalid;
5955 }
5956
5957
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5958 {
5959 return qe_invalid;
5960 }
5961
5962
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5963 {
5964 return qe_invalid;
5965 }
5966
5967
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5968 {
5969 return qe_invalid;
5970 }
5971
5972
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5973 {
5974 return qe_invalid;
5975 }
5976
5977
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5978 {
5979 return qe_invalid;
5980 }
5981
5982
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5983 {
5984 return qe_invalid;
5985 }
5986
5987
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5988 {
5989 return qe_invalid;
5990 }
5991
5992
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5993 {
5994 return qe_invalid;
5995 }
5996
5997
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5998 {
5999 return qe_invalid;
6000 }
6001
6002
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
6003 {
6004 return qe_invalid;
6005 }
6006
6007
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
6008 {
6009 return qe_invalid;
6010 }
6011
6012
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
6013 {
6014 return qe_invalid;
6015 }
6016
6017
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
6018 {
6019 return qe_invalid;
6020 }
6021
6022
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
6023 {
6024 return qe_invalid;
6025 }
6026
6027
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
6028 {
6029 return qe_invalid;
6030 }
6031
6032
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
6033 {
6034 return qe_invalid;
6035 }
6036
6037
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
6038 {
6039 return qe_invalid;
6040 }
6041
6042 9 temp_misc.colors.msgtext = 0x01;
6043
6044
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
6045 {
6046
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6047 {
6048
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6049 {
6050 return qe_invalid;
6051 }
6052 28 }
6053 4 }
6054
6055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6056 {
6057 for(int32_t i=0; i<256; i++)
6058 {
6059 if(!p_getc(&tempbyte,f,true))
6060 {
6061 return qe_invalid;
6062 }
6063 }
6064 }
6065
6066
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6067 {
6068 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6069 {
6070 return qe_invalid;
6071 }
6072 }
6073
6074 //save game icons
6075
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6077 {
6078 4 icons=3;
6079 4 }
6080
6081
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6082 {
6083
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6084 {
6085 return qe_invalid;
6086 }
6087 32 }
6088 9 }
6089
6090
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
6091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6092 {
6093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6094 {
6095 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6096 4 }
6097
6098 4 return 0;
6099 }
6100
6101 //pond information
6102
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
6103 {
6104 if((Header->zelda_version == 0x192)&&(Header->build<146))
6105 {
6106 pondsize=25;
6107 }
6108
6109 for(int32_t i=0; i<ponds; i++)
6110 {
6111 for(int32_t j=0; j<pondsize; j++)
6112 {
6113 if(!p_getc(&tempbyte,f,true))
6114 {
6115 return qe_invalid;
6116
6117 }
6118 }
6119 }
6120 }
6121
6122 //end string
6123
1/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version < 0x192)||
6124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6125 {
6126 if(!p_getc(&tempbyte,f,true))
6127 {
6128 return qe_invalid;
6129 }
6130
6131 temp_misc.endstring=tempbyte;
6132
6133 if(!p_getc(&tempbyte,f,true))
6134 {
6135 return qe_invalid;
6136 }
6137 }
6138 else
6139 {
6140
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&temp_misc.endstring,f,true))
6141 {
6142 return qe_invalid;
6143 }
6144 }
6145
6146 //expansion
6147
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
6148 {
6149 if((Header->zelda_version == 0x192)&&(Header->build<73))
6150 {
6151 expansionsize=99*2;
6152 }
6153
6154 for(int32_t i=0; i<expansionsize; i++)
6155 {
6156 if(!p_getc(&tempbyte,f,true))
6157 {
6158 return qe_invalid;
6159 }
6160 }
6161 }
6162 //shops v8
6163
6164
6165
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version >= 8)
6166 {
6167
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 29 times.
445 for(int32_t i=0; i<shops; i++)
6168 {
6169
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 416 times.
1664 for(int32_t j=0; j<3; j++)
6170 {
6171
1/2
✓ Branch 0 taken 1248 times.
✗ Branch 1 not taken.
1248 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6172 return qe_invalid;
6173 1248 }
6174 416 }
6175 29 }
6176
6177 110 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6178 110 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6179 110 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6180
6181 //v9 includes quest misc[32]
6182
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version >= 9)
6183 {
6184
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for ( int32_t q = 0; q < 32; q++ )
6185 {
6186
1/2
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
928 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6187 return qe_invalid;
6188 928 }
6189
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for ( int32_t q = 0; q < 32; q++ )
6190 {
6191
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 928 times.
119712 for ( int32_t j = 0; j < 128; j++ )
6192
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6193 return qe_invalid;
6194 928 }
6195 29 }
6196
6197
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 11 )
6198 {
6199
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6200 return qe_invalid;
6201 29 }
6202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 else if(s_version < 11 )
6203 {
6204 81 temp_misc.zscript_last_compiled_version = -1;
6205 81 }
6206
6207 110 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6208
6209
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 12)
6210 {
6211 byte spr;
6212
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t q = 0; q < sprMAX; ++q)
6213 {
6214
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&spr,f,true))
6215 return qe_invalid;
6216 7424 temp_misc.sprites[q] = spr;
6217 7424 }
6218 29 }
6219 else
6220 {
6221 81 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6222 //temp_misc.sprites[sprFALL] = ;
6223 }
6224
6225
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 13)
6226 {
6227
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(size_t q = 0; q < 64; ++q)
6228 {
6229 1856 bottletype* bt = &(temp_misc.bottle_types[q]);
6230
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!pfread(bt->name, 32, f, true))
6231 return qe_invalid;
6232
2/2
✓ Branch 0 taken 5568 times.
✓ Branch 1 taken 1856 times.
7424 for(size_t j = 0; j < 3; ++j)
6233 {
6234
1/2
✓ Branch 0 taken 5568 times.
✗ Branch 1 not taken.
5568 if (!p_getc(&(bt->counter[j]), f, true))
6235 return qe_invalid;
6236
1/2
✓ Branch 0 taken 5568 times.
✗ Branch 1 not taken.
5568 if (!p_igetw(&(bt->amount[j]), f, true))
6237 return qe_invalid;
6238 5568 }
6239
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!p_getc(&(bt->flags), f, true))
6240 return qe_invalid;
6241
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!p_getc(&(bt->next_type), f, true))
6242 return qe_invalid;
6243 1856 }
6244
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(size_t q = 0; q < 256; ++q)
6245 {
6246 7424 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6247
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if (!pfread(bst->name, 32, f, true))
6248 return qe_invalid;
6249
2/2
✓ Branch 0 taken 22272 times.
✓ Branch 1 taken 7424 times.
29696 for(size_t j = 0; j < 3; ++j)
6250 {
6251
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_getc(&(bst->fill[j]), f, true))
6252 return qe_invalid;
6253
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->comb[j]), f, true))
6254 return qe_invalid;
6255
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_getc(&(bst->cset[j]), f, true))
6256 return qe_invalid;
6257
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->price[j]), f, true))
6258 return qe_invalid;
6259
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->str[j]), f, true))
6260 return qe_invalid;
6261 22272 }
6262 7424 }
6263 29 }
6264 else
6265 {
6266
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 81 times.
5265 for(size_t q = 0; q < 64; ++q)
6267 5184 temp_misc.bottle_types[q].clear();
6268
2/2
✓ Branch 0 taken 20736 times.
✓ Branch 1 taken 81 times.
20817 for(size_t q = 0; q < 256; ++q)
6269 20736 temp_misc.bottle_shop_types[q].clear();
6270 }
6271
6272
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 14)
6273 {
6274 byte msfx;
6275
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t q = 0; q < sfxMAX; ++q)
6276 {
6277
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&msfx,f,true))
6278 return qe_invalid;
6279 7424 temp_misc.miscsfx[q] = msfx;
6280 7424 }
6281 29 }
6282 else
6283 {
6284 81 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6285 81 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6286 81 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6287 }
6288
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version < 15)
6289 {
6290 81 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6291 81 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6292 81 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6293 81 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6294 81 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6295 81 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6296 81 }
6297
6298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
6299 {
6300 110 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6301 110 }
6302
6303 110 return 0;
6304 114 }
6305
6306 extern char *item_string[ITEMCNT];
6307 extern const char *old_item_string[iLast];
6308 extern char *weapon_string[WPNCNT];
6309 extern const char *old_weapon_string[wLast];
6310
6311 114 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6312 {
6313 byte padding;
6314 int32_t dummy;
6315 114 word items_to_read=MAXITEMS;
6316 itemdata tempitem;
6317 114 word s_version=0, s_cversion=0;
6318 word dummy_word;
6319
6320
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(version < 0x186)
6321 {
6322 items_to_read=64;
6323 }
6324
6325
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
6326 {
6327 110 items_to_read=0;
6328
6329 //section version info
6330
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
6331 {
6332 return qe_invalid;
6333 }
6334
6335 110 FFCore.quest_format[vItems] = s_version;
6336
6337 //al_trace("Items version %d\n", s_version);
6338
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
6339 {
6340 return qe_invalid;
6341 }
6342
6343 //section size
6344
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
6345 {
6346 return qe_invalid;
6347 }
6348
6349 //finally... section data
6350
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&items_to_read,f,true))
6351 {
6352 return qe_invalid;
6353 }
6354 110 }
6355
6356
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version>1)
6357 {
6358
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<items_to_read; i++)
6359 {
6360 char tempname[64];
6361
6362
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!pfread(tempname, 64, f, keepdata))
6363 {
6364 return qe_invalid;
6365 }
6366
6367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(keepdata)
6368 {
6369 26880 strcpy(item_string[i], tempname);
6370 26880 }
6371 26880 }
6372 105 }
6373 else
6374 {
6375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6376 {
6377
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6378 {
6379 2304 reset_itemname(i);
6380 2304 }
6381 9 }
6382 }
6383
6384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
6385 {
6386
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMS; i++)
6387 {
6388 29184 itemdata& id = itemsbuf[i];
6389 29184 memset(&id, 0, sizeof(itemdata));
6390 29184 id.count=-1;
6391 29184 id.playsound=WAV_SCALE;
6392 29184 reset_itembuf(&id,i);
6393 29184 }
6394 114 }
6395
6396
2/2
✓ Branch 0 taken 28254 times.
✓ Branch 1 taken 114 times.
28368 for(int32_t i=0; i<items_to_read; i++)
6397 {
6398 28254 memset(&tempitem, 0, sizeof(itemdata));
6399 28254 reset_itembuf(&tempitem,i);
6400
6401
6402
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 20830 times.
28254 if ( s_version > 35 ) //expanded tiles
6403 {
6404
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tile,f,true))
6405 {
6406 return qe_invalid;
6407 }
6408 7424 }
6409 else
6410 {
6411
1/2
✓ Branch 0 taken 20830 times.
✗ Branch 1 not taken.
20830 if(!p_igetw(&tempitem.tile,f,true))
6412 {
6413 return qe_invalid;
6414 }
6415 }
6416
6417
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.misc_flags,f,true))
6418 {
6419 return qe_invalid;
6420 }
6421
6422
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.csets,f,true))
6423 {
6424 return qe_invalid;
6425 }
6426
6427
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.frames,f,true))
6428 {
6429 return qe_invalid;
6430 }
6431
6432
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.speed,f,true))
6433 {
6434 return qe_invalid;
6435 }
6436
6437
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.delay,f,true))
6438 {
6439 return qe_invalid;
6440 }
6441
6442
2/2
✓ Branch 0 taken 27230 times.
✓ Branch 1 taken 1024 times.
28254 if(version < 0x193)
6443 {
6444
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6445 {
6446 return qe_invalid;
6447 }
6448
6449
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6450 {
6451
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6452 {
6453 case iShield:
6454 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6455 4 break;
6456
6457 case iMShield:
6458 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6459 4 break;
6460
6461 default:
6462 1016 tempitem.ltm=0;
6463 1016 break;
6464 }
6465
6466 1024 tempitem.count=-1;
6467 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6468 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6469 1024 tempitem.family=0xFF;
6470 1024 tempitem.playsound=WAV_SCALE;
6471 1024 reset_itembuf(&tempitem,i);
6472
6473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6474 {
6475 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6476 1024 }
6477
6478 1024 continue;
6479 }
6480 }
6481
6482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27230 times.
27230 if(!p_igetl(&tempitem.ltm,f,true))
6483 {
6484 return qe_invalid;
6485 }
6486
6487
1/2
✓ Branch 0 taken 27230 times.
✗ Branch 1 not taken.
27230 if(version < 0x193)
6488 {
6489 for(int32_t q=0; q<12; q++)
6490 {
6491 if(!p_getc(&padding,f,true))
6492 {
6493 return qe_invalid;
6494 }
6495 }
6496 }
6497
6498
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 350 times.
27230 if(s_version>1)
6499 {
6500
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if ( s_version >= 31 )
6501 {
6502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.family,f,true))
6503 {
6504 return qe_invalid;
6505 }
6506 7424 }
6507 else
6508 {
6509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.family,f,true))
6510 {
6511 return qe_invalid;
6512 }
6513 }
6514
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version < 16)
6515 if(tempitem.family == 0xFF)
6516 tempitem.family = itype_misc;
6517
6518
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.fam_type,f,true))
6519 {
6520 return qe_invalid;
6521 }
6522
6523
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version>5)
6524 {
6525
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if(s_version>=31)
6526 {
6527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.power,f,true))
6528 {
6529 return qe_invalid;
6530 }
6531 7424 }
6532 else
6533 {
6534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.power,f,true))
6535 {
6536 return qe_invalid;
6537 }
6538 }
6539
6540 //converted flags from 16b to 32b -Z
6541
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version < 41 )
6542 {
6543
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&tempitem.flags,f,true))
6544 {
6545 return qe_invalid;
6546 }
6547 19456 }
6548 else
6549 {
6550
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.flags,f,true))
6551 {
6552 return qe_invalid;
6553 }
6554 }
6555 26880 }
6556 else
6557 {
6558 //tempitem.power = tempitem.fam_type;
6559 char tempchar;
6560
6561 if(!p_getc(&tempchar,f,true))
6562 {
6563 return qe_invalid;
6564 }
6565
6566 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6567 }
6568
6569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.script,f,true))
6570 {
6571 return qe_invalid;
6572 }
6573
6574
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<=3)
6575 {
6576 if(tempitem.script > NUMSCRIPTITEM)
6577 {
6578 tempitem.script = 0;
6579 }
6580 }
6581
6582
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.count,f,true))
6583 {
6584 return qe_invalid;
6585 }
6586
6587
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetw(&tempitem.amount,f,true))
6588 {
6589 return qe_invalid;
6590 }
6591
6592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.collect_script,f,true))
6593 {
6594 return qe_invalid;
6595 }
6596
6597
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<=3)
6598 {
6599 if(tempitem.collect_script > NUMSCRIPTITEM)
6600 {
6601 tempitem.collect_script = 0;
6602 }
6603 }
6604
6605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.setmax,f,true))
6606 {
6607 return qe_invalid;
6608 }
6609
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.max,f,true))
6611 {
6612 return qe_invalid;
6613 }
6614
6615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.playsound,f,true))
6616 {
6617 return qe_invalid;
6618 }
6619
6620
2/2
✓ Branch 0 taken 215040 times.
✓ Branch 1 taken 26880 times.
241920 for(int32_t j=0; j<8; j++)
6621 {
6622
1/2
✓ Branch 0 taken 215040 times.
✗ Branch 1 not taken.
215040 if(!p_igetl(&tempitem.initiald[j],f,true))
6623 {
6624 return qe_invalid;
6625 }
6626 215040 }
6627
6628
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 26880 times.
80640 for(int32_t j=0; j<2; j++)
6629 {
6630
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempitem.initiala[j],f,true))
6631 {
6632 return qe_invalid;
6633 }
6634 53760 }
6635
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>4)
6637 {
6638
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version>5)
6639 {
6640
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn,f,true))
6641 {
6642 return qe_invalid;
6643 }
6644
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn2,f,true))
6646 {
6647 return qe_invalid;
6648 }
6649
6650
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn3,f,true))
6651 {
6652 return qe_invalid;
6653 }
6654
6655
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn4,f,true))
6656 {
6657 return qe_invalid;
6658 }
6659
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>=15)
6661 {
6662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn5,f,true))
6663 {
6664 return qe_invalid;
6665 }
6666
6667
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn6,f,true))
6668 {
6669 return qe_invalid;
6670 }
6671
6672
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn7,f,true))
6673 {
6674 return qe_invalid;
6675 }
6676
6677
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn8,f,true))
6678 {
6679 return qe_invalid;
6680 }
6681
6682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn9,f,true))
6683 {
6684 return qe_invalid;
6685 }
6686
6687
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn10,f,true))
6688 {
6689 return qe_invalid;
6690 }
6691 26880 }
6692
6693
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.pickup_hearts,f,true))
6694 {
6695 return qe_invalid;
6696 }
6697
6698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version<15)
6699 {
6700 if(!p_igetw(&dummy_word,f,true))
6701 {
6702 return qe_invalid;
6703 }
6704
6705 tempitem.misc1=dummy_word;
6706
6707 if(!p_igetw(&dummy_word,f,true))
6708 {
6709 return qe_invalid;
6710 }
6711
6712 tempitem.misc2=dummy_word;
6713 }
6714 else
6715 {
6716
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc1,f,true))
6717 {
6718 return qe_invalid;
6719 }
6720
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc2,f,true))
6722 {
6723 return qe_invalid;
6724 }
6725
6726 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6727
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<24)
6728 {
6729 if(tempitem.family==itype_shield)
6730 {
6731 tempitem.misc1|=shSCRIPT;
6732 }
6733 }
6734 }
6735
6736
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if(s_version < 53)
6737 {
6738 byte tempbyte;
6739
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempbyte,f,true))
6740 {
6741 return qe_invalid;
6742 }
6743 19456 tempitem.cost_amount[0] = tempbyte;
6744 19456 }
6745 else
6746 {
6747
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < 2; ++q)
6748 {
6749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6750 {
6751 return qe_invalid;
6752 }
6753 14848 }
6754 }
6755 26880 }
6756 else
6757 {
6758 char tempchar;
6759
6760 if(!p_getc(&tempchar,f,true))
6761 {
6762 return qe_invalid;
6763 }
6764
6765 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6766 }
6767
6768 // June 2007: more misc. attributes
6769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>=12)
6770 {
6771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version<15)
6772 {
6773 if(!p_igetw(&dummy_word,f,true))
6774 {
6775 return qe_invalid;
6776 }
6777
6778 tempitem.misc3=dummy_word;
6779
6780 if(!p_igetw(&dummy_word,f,true))
6781 {
6782 return qe_invalid;
6783 }
6784
6785 tempitem.misc4=dummy_word;
6786 }
6787 else
6788 {
6789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc3,f,true))
6790 {
6791 return qe_invalid;
6792 }
6793
6794
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc4,f,true))
6795 {
6796 return qe_invalid;
6797 }
6798
6799
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc5,f,true))
6800 {
6801 return qe_invalid;
6802 }
6803
6804
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc6,f,true))
6805 {
6806 return qe_invalid;
6807 }
6808
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc7,f,true))
6810 {
6811 return qe_invalid;
6812 }
6813
6814
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc8,f,true))
6815 {
6816 return qe_invalid;
6817 }
6818
6819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc9,f,true))
6820 {
6821 return qe_invalid;
6822 }
6823
6824
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc10,f,true))
6825 {
6826 return qe_invalid;
6827 }
6828 }
6829
6830
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.usesound,f,true))
6831 {
6832 return qe_invalid;
6833 }
6834
6835
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if(s_version >= 49)
6836 {
6837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.usesound2,f,true))
6838 {
6839 return qe_invalid;
6840 }
6841 7424 }
6842 19456 else tempitem.usesound2 = 0;
6843
6844
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
26880 if(s_version < 50 && tempitem.family == itype_mirror)
6845 {
6846 //Split continue/dmap warp effect/sfx, port for old
6847 tempitem.misc2 = tempitem.misc1;
6848 tempitem.usesound2 = tempitem.usesound;
6849 }
6850 26880 }
6851 26880 }
6852
6853
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6854 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.useweapon,f,true))
6856 {
6857 return qe_invalid;
6858 }
6859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.usedefence,f,true))
6860 {
6861 return qe_invalid;
6862 }
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weaprange,f,true))
6864 {
6865 return qe_invalid;
6866 }
6867
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weapduration,f,true))
6868 {
6869 return qe_invalid;
6870 }
6871
2/2
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 7424 times.
81664 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6872 {
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74240 times.
74240 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6874 {
6875 return qe_invalid;
6876 }
6877 74240 }
6878 7424 }
6879
6880
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6881 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6882
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.duplicates,f,true))
6883 {
6884 return qe_invalid;
6885 }
6886
2/2
✓ Branch 0 taken 59392 times.
✓ Branch 1 taken 7424 times.
66816 for ( int32_t q = 0; q < INITIAL_D; q++ )
6887 {
6888
1/2
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
59392 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6889 {
6890 return qe_invalid;
6891 }
6892 59392 }
6893
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for ( int32_t q = 0; q < INITIAL_A; q++ )
6894 {
6895
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6896 {
6897 return qe_invalid;
6898 }
6899 14848 }
6900
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.drawlayer,f,true))
6902 {
6903 return qe_invalid;
6904 }
6905
6906
6907
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hxofs,f,true))
6908 {
6909 return qe_invalid;
6910 }
6911
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hyofs,f,true))
6912 {
6913 return qe_invalid;
6914 }
6915
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hxsz,f,true))
6916 {
6917 return qe_invalid;
6918 }
6919
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hysz,f,true))
6920 {
6921 return qe_invalid;
6922 }
6923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.hzsz,f,true))
6924 {
6925 return qe_invalid;
6926 }
6927
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.xofs,f,true))
6928 {
6929 return qe_invalid;
6930 }
6931
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.yofs,f,true))
6932 {
6933 return qe_invalid;
6934 }
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6936 {
6937 return qe_invalid;
6938 }
6939
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hysz,f,true))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6952 {
6953 return qe_invalid;
6954 }
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_xofs,f,true))
6956 {
6957 return qe_invalid;
6958 }
6959
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_yofs,f,true))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetw(&tempitem.weaponscript,f,true))
6964 {
6965 return qe_invalid;
6966 }
6967
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.wpnsprite,f,true))
6968 {
6969 return qe_invalid;
6970 }
6971 7424 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6972
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < num_cost_tmr; ++q)
6973 {
6974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6975 {
6976 return qe_invalid;
6977 }
6978 14848 }
6979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 for(auto q = num_cost_tmr; q < 2; ++q)
6980 tempitem.magiccosttimer[q] = 0;
6981 7424 }
6982
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6983 {
6984 //Item Size FLags, TileWidth, TileHeight
6985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6986 {
6987 return qe_invalid;
6988 }
6989
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tilew,f,true))
6990 {
6991 return qe_invalid;
6992 }
6993
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tileh,f,true))
6994 {
6995 return qe_invalid;
6996 }
6997 7424 }
6998
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 29 ) //! More new vars.
6999 {
7000 //Item Size FLags, TileWidth, TileHeight
7001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
7002 {
7003 return qe_invalid;
7004 }
7005
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_tilew,f,true))
7006 {
7007 return qe_invalid;
7008 }
7009
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_tileh,f,true))
7010 {
7011 return qe_invalid;
7012 }
7013 7424 }
7014
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 30 ) //! More new vars.
7015 {
7016 //Pickup Type
7017
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.pickup,f,true))
7018 {
7019 return qe_invalid;
7020 }
7021 7424 }
7022
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 32 ) //! More new vars.
7023 {
7024 //Pickup Type
7025
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempitem.pstring,f,true))
7026 {
7027 return qe_invalid;
7028 }
7029 7424 }
7030
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 33 ) //! More new vars.
7031 {
7032 //Pickup Type
7033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
7034 {
7035 return qe_invalid;
7036 }
7037 7424 }
7038
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 34 ) //! cost counter
7039 {
7040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(s_version < 53)
7041 {
7042 if(!p_getc(&tempitem.cost_counter[0],f,true))
7043 {
7044 return qe_invalid;
7045 }
7046 }
7047 else
7048 {
7049
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < 2; ++q)
7050 {
7051
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.cost_counter[q],f,true))
7052 {
7053 return qe_invalid;
7054 }
7055 14848 }
7056 }
7057 7424 }
7058
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 44 ) //! sprite scripts
7059 {
7060
2/2
✓ Branch 0 taken 59392 times.
✓ Branch 1 taken 7424 times.
66816 for ( int32_t q = 0; q < 8; q++ )
7061 {
7062
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7063 {
7064
1/2
✓ Branch 0 taken 3860480 times.
✗ Branch 1 not taken.
3860480 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7065 {
7066 return qe_invalid;
7067 }
7068 3860480 }
7069
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7070 {
7071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3860480 times.
3860480 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7072 {
7073 return qe_invalid;
7074 }
7075 3860480 }
7076
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7077 {
7078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3860480 times.
3860480 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7079 {
7080 return qe_invalid;
7081 }
7082 3860480 }
7083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59392 times.
59392 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7084 {
7085 return qe_invalid;
7086 }
7087
7088 59392 }
7089
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for ( int32_t q = 0; q < 2; q++ )
7090 {
7091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7092 {
7093 return qe_invalid;
7094 }
7095 14848 }
7096 //Pickup Type
7097
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempitem.sprite_script,f,true))
7098 {
7099 return qe_invalid;
7100 }
7101 7424 }
7102
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 48 ) //! pickup flags
7103 {
7104
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7105 {
7106 return qe_invalid;
7107 }
7108 7424 }
7109
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 5632 times.
26880 if ( s_version >= 57 )
7110 {
7111 5632 std::string str;
7112
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 5632 times.
✗ Branch 3 not taken.
5632 if(!p_getcstr(&str,f,true))
7113 return qe_invalid;
7114 5632 strncpy(tempitem.display_name,str.c_str(),255);
7115
1/3
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5632 }
7116 26880 }
7117 else
7118 {
7119 350 tempitem.count=-1;
7120 350 tempitem.family=itype_misc;
7121 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7122 350 tempitem.playsound=WAV_SCALE;
7123 350 reset_itembuf(&tempitem,i);
7124 }
7125
7126
1/2
✓ Branch 0 taken 27230 times.
✗ Branch 1 not taken.
27230 if(keepdata==true)
7127 {
7128 27230 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7129 27230 }
7130 else if(zgpmode)
7131 {
7132 itemsbuf[i].tile=tempitem.tile;
7133 itemsbuf[i].misc_flags=tempitem.misc_flags;
7134 itemsbuf[i].csets=tempitem.csets;
7135 itemsbuf[i].frames=tempitem.frames;
7136 itemsbuf[i].speed=tempitem.speed;
7137 itemsbuf[i].delay=tempitem.delay;
7138 itemsbuf[i].ltm=tempitem.ltm;
7139 }
7140 27230 }
7141
7142 //////////////////////////////////////////////////////
7143 // Now do any updates because of new item additions
7144 // (These can't be done above because items_to_read
7145 // might be too low.)
7146 //////////////////////////////////////////////////////
7147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
7148 {
7149
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMS; i++)
7150 {
7151 29184 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7152
7153 //Account for older quests that didn't have an actual item for the used letter
7154
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 2 && i==iLetterUsed)
7155 {
7156 9 reset_itembuf(&tempitem, iLetterUsed);
7157 9 strcpy(item_string[i],old_item_string[i]);
7158 9 tempitem.tile = itemsbuf[iLetter].tile;
7159 9 tempitem.csets = itemsbuf[iLetter].csets;
7160 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7161 9 tempitem.frames = itemsbuf[iLetter].frames;
7162 9 tempitem.speed = itemsbuf[iLetter].speed;
7163 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7164 9 }
7165
7166
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 3)
7167 {
7168
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7169 {
7170 case iRocsFeather:
7171 case iHoverBoots:
7172 case iSpinScroll:
7173 case iL2SpinScroll:
7174 case iCrossScroll:
7175 case iQuakeScroll:
7176 case iL2QuakeScroll:
7177 case iWhispRing:
7178 case iL2WhispRing:
7179 case iChargeRing:
7180 case iL2ChargeRing:
7181 case iPerilScroll:
7182 case iWalletL3:
7183 case iQuiverL4:
7184 case iBombBagL4:
7185 case iBracelet:
7186 case iL2Bracelet:
7187 case iOldGlove:
7188 case iL2Ladder:
7189 case iWealthMedal:
7190 case iL2WealthMedal:
7191 case iL3WealthMedal:
7192 198 reset_itembuf(&tempitem, i);
7193 198 strcpy(item_string[i],old_item_string[i]);
7194 198 break;
7195
7196 case iSShield:
7197 9 reset_itembuf(&tempitem, i);
7198 9 strcpy(item_string[i],old_item_string[i]);
7199 9 strcpy(item_string[iShield],old_item_string[iShield]);
7200 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7201 9 break;
7202 }
7203 2304 }
7204
7205
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 5)
7206 {
7207
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7208 {
7209 case iHeartRing:
7210 case iL2HeartRing:
7211 case iL3HeartRing:
7212 case iMagicRing:
7213 case iL2MagicRing:
7214 case iL3MagicRing:
7215 case iL4MagicRing:
7216 63 reset_itembuf(&tempitem, i);
7217 63 strcpy(item_string[i],old_item_string[i]);
7218 63 break;
7219 }
7220 2304 }
7221
7222
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7223 {
7224
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7225 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7226
7227
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7228 {
7229 case iTriforce:
7230 9 tempitem.fam_type=1;
7231 9 break;
7232
7233 case iBigTri:
7234 9 tempitem.fam_type=0;
7235 9 break;
7236
7237 case iBombs:
7238 9 tempitem.fam_type=i_bomb;
7239 9 tempitem.power=4;
7240 9 tempitem.wpn=wBOMB;
7241 9 tempitem.wpn2=wBOOM;
7242 9 tempitem.misc1 = 50;
7243
7244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7245
7246 9 break;
7247
7248 case iSBomb:
7249 9 tempitem.fam_type=i_sbomb;
7250 9 tempitem.power=16;
7251 9 tempitem.wpn=wSBOMB;
7252 9 tempitem.wpn2=wSBOOM;
7253 9 tempitem.misc1 = 50;
7254
7255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7256
7257 9 break;
7258
7259 case iBook:
7260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 113))
7261 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7262
7263 9 break;
7264
7265 case iSArrow:
7266 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7267 9 tempitem.power=4;
7268 9 tempitem.flags|=ITEM_GAMEDATA;
7269 9 tempitem.wpn=wSARROW;
7270 9 break;
7271
7272 case iGArrow:
7273 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7274 9 tempitem.power=8;
7275 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7276 9 tempitem.wpn=wGARROW;
7277 9 break;
7278
7279 case iBrang:
7280 9 tempitem.power=0;
7281 9 tempitem.wpn=wBRANG;
7282 9 tempitem.misc1=36;
7283 9 break;
7284
7285 case iMBrang:
7286 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7287 9 tempitem.power=0;
7288 9 tempitem.wpn=wMBRANG;
7289 9 break;
7290
7291 case iFBrang:
7292 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7293 9 tempitem.power=2;
7294 9 tempitem.wpn=wFBRANG;
7295 9 break;
7296
7297 case iBoots:
7298 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7299 9 tempitem.power=7;
7300 9 break;
7301
7302 case iWand:
7303 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7304 9 tempitem.power=2;
7305 9 tempitem.wpn=wWAND;
7306 9 tempitem.wpn3=wMAGIC;
7307 9 break;
7308
7309 case iBCandle:
7310 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7311 9 tempitem.power=1;
7312 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7313 9 tempitem.wpn3=wFIRE;
7314 9 break;
7315
7316 case iRCandle:
7317 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7318 9 tempitem.power=1;
7319 9 tempitem.wpn3=wFIRE;
7320 9 break;
7321
7322 case iSword:
7323 9 tempitem.power=1;
7324 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7325 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7326 9 tempitem.wpn2=wSWORDSLASH;
7327 9 break;
7328
7329 case iWSword:
7330 9 tempitem.power=2;
7331 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7332 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7333 9 tempitem.wpn2=wWSWORDSLASH;
7334 9 break;
7335
7336 case iMSword:
7337 9 tempitem.power=4;
7338 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7339 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7340 9 tempitem.wpn2=wMSWORDSLASH;
7341 9 break;
7342
7343 case iXSword:
7344 9 tempitem.power=8;
7345 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7346 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7347 9 tempitem.wpn2=wXSWORDSLASH;
7348 9 break;
7349
7350 case iDivineProtection:
7351 9 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7352 9 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7353 9 tempitem.wpn=wDIVINEPROTECTION1A;
7354 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7355 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7356 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7357 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7358 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7359 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7360 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7361 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7362 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7363 9 tempitem.misc1=512;
7364 9 tempitem.cost_amount[0]=64;
7365 9 break;
7366
7367 case iLens:
7368 9 tempitem.misc1=60;
7369 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7370 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7371 9 break;
7372
7373 case iArrow:
7374 9 tempitem.power=2;
7375 9 tempitem.wpn=wARROW;
7376 9 break;
7377
7378 case iHoverBoots:
7379 9 tempitem.misc1=45;
7380 9 tempitem.wpn=iwHover;
7381 9 break;
7382
7383 case iDivineFire:
7384 9 tempitem.power=8;
7385 9 tempitem.wpn=wDIVINEFIRE1A;
7386 9 tempitem.wpn2=wDIVINEFIRE1B;
7387 9 tempitem.wpn3=wDIVINEFIRES1A;
7388 9 tempitem.wpn4=wDIVINEFIRES1B;
7389 9 tempitem.misc1 = 32;
7390 9 tempitem.misc2 = 200;
7391 9 tempitem.cost_amount[0]=32;
7392 9 break;
7393
7394 case iDivineEscape:
7395 9 tempitem.cost_amount[0]=32;
7396 9 break;
7397
7398 case iHookshot:
7399 9 tempitem.power=0;
7400 9 tempitem.flags&=~ITEM_FLAG1;
7401 9 tempitem.wpn=wHSHEAD;
7402 9 tempitem.wpn2=wHSCHAIN_H;
7403 9 tempitem.wpn4=wHSHANDLE;
7404 9 tempitem.wpn3=wHSCHAIN_V;
7405 9 tempitem.misc1=50;
7406 9 tempitem.misc2=100;
7407 9 break;
7408
7409 case iLongshot:
7410 9 tempitem.power=0;
7411 9 tempitem.flags&=~ITEM_FLAG1;
7412 9 tempitem.wpn=wLSHEAD;
7413 9 tempitem.wpn2=wLSCHAIN_H;
7414 9 tempitem.wpn4=wLSHANDLE;
7415 9 tempitem.wpn3=wLSCHAIN_V;
7416 9 tempitem.misc1=99;
7417 9 tempitem.misc2=100;
7418 9 break;
7419
7420 case iHammer:
7421 9 tempitem.power=4;
7422 9 tempitem.wpn=wHAMMER;
7423 9 tempitem.wpn2=iwHammerSmack;
7424 9 break;
7425
7426 case iCByrna:
7427 9 tempitem.power=1;
7428 9 tempitem.wpn=wCBYRNA;
7429 9 tempitem.wpn2=wCBYRNASLASH;
7430 9 tempitem.wpn3=wCBYRNAORB;
7431 9 tempitem.misc1=4;
7432 9 tempitem.misc2=16;
7433 9 tempitem.misc3=1;
7434 9 tempitem.cost_amount[0]=1;
7435 9 break;
7436
7437 case iWhistle:
7438 9 tempitem.wpn=wWIND;
7439 9 tempitem.misc1=3;
7440 9 tempitem.flags|=ITEM_FLAG1;
7441 9 break;
7442
7443 case iBRing:
7444 9 tempitem.power=2;
7445 9 tempitem.misc1=spBLUE;
7446 9 break;
7447
7448 case iRRing:
7449 9 tempitem.power=4;
7450 9 tempitem.misc1=spRED;
7451 9 break;
7452
7453 case iGRing:
7454 9 tempitem.power=8;
7455 9 tempitem.misc1=spGOLD;
7456 9 break;
7457
7458 case iSpinScroll:
7459 9 tempitem.power = 2;
7460 9 tempitem.misc1 = 1;
7461 9 break;
7462
7463 case iL2SpinScroll:
7464 9 tempitem.family=itype_spinscroll2;
7465 9 tempitem.fam_type=1;
7466 9 tempitem.cost_amount[0]=8;
7467 9 tempitem.power=2;
7468 9 tempitem.misc1 = 20;
7469 9 break;
7470
7471 case iQuakeScroll:
7472 9 tempitem.misc1=0x10;
7473 9 tempitem.misc2=64;
7474 9 break;
7475
7476 case iL2QuakeScroll:
7477 9 tempitem.family=itype_quakescroll2;
7478 9 tempitem.fam_type=1;
7479 9 tempitem.power = 2;
7480 9 tempitem.misc1=0x20;
7481 9 tempitem.misc2=192;
7482 9 tempitem.cost_amount[0]=8;
7483 9 break;
7484
7485 case iChargeRing:
7486 9 tempitem.misc1=64;
7487 9 tempitem.misc2=128;
7488 9 break;
7489
7490 case iL2ChargeRing:
7491 9 tempitem.misc1=32;
7492 9 tempitem.misc2=64;
7493 9 break;
7494
7495 case iOldGlove:
7496 9 tempitem.flags |= ITEM_FLAG1;
7497
7498 //fallthrough
7499 case iBombBagL4:
7500 case iWalletL3:
7501 case iQuiverL4:
7502 case iBracelet:
7503 45 tempitem.power = 1;
7504 45 break;
7505
7506 case iL2Bracelet:
7507 9 tempitem.power = 2;
7508 9 break;
7509
7510 case iMKey:
7511 9 tempitem.power=0xFF;
7512 9 tempitem.flags |= ITEM_FLAG1;
7513 9 break;
7514 }
7515 2304 }
7516
7517
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 7)
7518 {
7519
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7520 {
7521 case iStoneAgony:
7522 case iStompBoots:
7523 case iPerilRing:
7524 case iWhimsicalRing:
7525 {
7526 36 reset_itembuf(&tempitem, i);
7527 36 strcpy(item_string[i],old_item_string[i]);
7528 36 break;
7529 }
7530 }
7531 2304 }
7532
7533
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 8) // May 2007: Some corrections.
7534 {
7535
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7536 {
7537 case iMShield:
7538 9 tempitem.misc1|=shFLAME;
7539 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7540
7541
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7542 {
7543 tempitem.misc2 |= shSWORD;
7544 }
7545
7546 // fallthrough
7547 case iShield:
7548 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7549
7550 // fallthrough
7551 case iSShield:
7552 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7553
7554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7555 {
7556 tempitem.misc2 |= shROCK;
7557 }
7558
7559 27 break;
7560
7561 case iWhispRing:
7562 9 tempitem.power=1;
7563 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7564 9 tempitem.misc1 = 3;
7565 9 break;
7566
7567 case iL2WhispRing:
7568 9 tempitem.power=0;
7569 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7570 9 tempitem.misc1 = 3;
7571 9 break;
7572
7573 case iL2Ladder:
7574 case iBow:
7575 case iCByrna:
7576 27 tempitem.power = 1;
7577 27 break;
7578 }
7579 2304 }
7580
7581
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 9 && i==iClock)
7582 {
7583 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7584 9 }
7585
7586 //add the misc flag for bomb
7587
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 10 && tempitem.family == itype_bomb)
7588 {
7589 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7590 9 }
7591
7592
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
29184 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7593 {
7594 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7595 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7596 18 }
7597
7598
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 12) // June 2007: More Misc. attributes.
7599 {
7600
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7601 {
7602 case iFBrang:
7603 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7604
7605 //fallthrough
7606 case iMBrang:
7607 18 tempitem.misc3 |= shSWORD|shMAGIC;
7608
7609 //fallthrough
7610 case iHookshot:
7611 case iLongshot:
7612 //fallthrough
7613 36 tempitem.misc3 |= shFIREBALL;
7614
7615 case iBrang:
7616 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7617 45 break;
7618 }
7619
7620
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7621 {
7622 case itype_hoverboots:
7623 9 tempitem.usesound = WAV_ZN1HOVER;
7624 9 break;
7625
7626 case itype_wand:
7627 9 tempitem.usesound = WAV_WAND;
7628 9 break;
7629
7630 case itype_book:
7631 9 tempitem.usesound = WAV_FIRE;
7632 9 break;
7633
7634 case itype_arrow:
7635 27 tempitem.usesound = WAV_ARROW;
7636 27 break;
7637
7638 case itype_hookshot:
7639 18 tempitem.usesound = WAV_HOOKSHOT;
7640 18 break;
7641
7642 case itype_brang:
7643 27 tempitem.usesound = WAV_BRANG;
7644 27 break;
7645
7646 case itype_shield:
7647 27 tempitem.usesound = WAV_CHINK;
7648 27 break;
7649
7650 case itype_sword:
7651 781 tempitem.usesound = WAV_SWORD;
7652 781 break;
7653
7654 case itype_whistle:
7655 9 tempitem.usesound = WAV_WHISTLE;
7656 9 break;
7657
7658 case itype_hammer:
7659 9 tempitem.usesound = WAV_HAMMER;
7660 9 break;
7661
7662 case itype_divinefire:
7663 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7664 9 break;
7665
7666 case itype_divineescape:
7667 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7668 9 break;
7669
7670 case itype_divineprotection:
7671 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7672 9 break;
7673
7674 case itype_bomb:
7675 case itype_sbomb:
7676 case itype_quakescroll:
7677 case itype_quakescroll2:
7678 36 tempitem.usesound = WAV_BOMB;
7679 36 break;
7680
7681 case itype_spinscroll:
7682 case itype_spinscroll2:
7683 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7684 18 break;
7685 }
7686 2304 }
7687
7688
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 13) // July 2007
7689 {
7690
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7691 {
7692 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7693 9 tempitem.power = 1;
7694 9 tempitem.flags|=ITEM_FLAG1;
7695 9 }
7696
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7697 9 tempitem.flags|=ITEM_FLAG1;
7698
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7699 {
7700 9 tempitem.flags|=ITEM_FLAG1;
7701 9 tempitem.power = 2;
7702 9 }
7703 2304 }
7704
7705
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 14) // August 2007
7706 {
7707
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7708 {
7709 18 tempitem.usesound = WAV_SCALE;
7710
7711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7712 18 tempitem.misc3=50;
7713 18 }
7714
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7715 {
7716 18 tempitem.flags |= ITEM_GAINOLD;
7717 18 }
7718 2304 }
7719
7720
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 17) // November 2007
7721 {
7722
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7723 {
7724 tempitem.wpn3 = wFIRE;
7725 }
7726
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7727 {
7728 9 tempitem.flags|=ITEM_FLAG1;
7729 9 }
7730 2304 }
7731
7732
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 18) // New Year's Eve 2007
7733 {
7734
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7735 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7736
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7737 9 tempitem.misc1 = 768; // Frames until it goes
7738
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7739 {
7740
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7741 {
7742 9 tempitem.misc2 = 1; // Cutscene 1
7743 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7744 9 }
7745 18 }
7746 2304 }
7747
7748
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 19) // January 2008
7749 {
7750
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7751 {
7752 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7753 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7754 9 }
7755 2304 }
7756
7757
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 20) // October 2008
7758 {
7759
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7760 {
7761 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7762 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7763 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7764 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7765 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7766 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7767 9 }
7768 2304 }
7769
7770
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 21) // November 2008
7771 {
7772
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7773 {
7774 tempitem.flags &= ~0x0100;
7775
7776 if(tempitem.family == itype_sword ||
7777 tempitem.family == itype_wand ||
7778 tempitem.family == itype_candle ||
7779 tempitem.family == itype_cbyrna)
7780 {
7781 tempitem.flags |= ITEM_FLAG4;
7782 }
7783 }
7784 2304 }
7785
7786
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 22) // September 2009
7787 {
7788
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7789 {
7790 18 tempitem.misc3 = tempitem.power/2;
7791 18 }
7792 2304 }
7793
7794
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 23) // March 2011
7795 {
7796
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7797 9 tempitem.wpn5 = wFIRE;
7798
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7799 9 tempitem.wpn2 = wFIRE;
7800 2304 }
7801
7802 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7803 // whether it was or not, and a lot of existing quests depended on the
7804 // incorrect behavior.
7805
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 25) // January 2012
7806 {
7807
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7808 36 tempitem.flags |= 16;
7809
7810
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7811 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7812 2304 }
7813
7814
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7815 {
7816
60/60
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 85 times.
✓ Branch 6 taken 168 times.
✓ Branch 7 taken 167 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 278 times.
✓ Branch 10 taken 252 times.
✓ Branch 11 taken 167 times.
✓ Branch 12 taken 259 times.
✓ Branch 13 taken 168 times.
✓ Branch 14 taken 84 times.
✓ Branch 15 taken 168 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 84 times.
✓ Branch 18 taken 255 times.
✓ Branch 19 taken 85 times.
✓ Branch 20 taken 86 times.
✓ Branch 21 taken 168 times.
✓ Branch 22 taken 84 times.
✓ Branch 23 taken 85 times.
✓ Branch 24 taken 84 times.
✓ Branch 25 taken 84 times.
✓ Branch 26 taken 84 times.
✓ Branch 27 taken 99 times.
✓ Branch 28 taken 84 times.
✓ Branch 29 taken 85 times.
✓ Branch 30 taken 84 times.
✓ Branch 31 taken 85 times.
✓ Branch 32 taken 168 times.
✓ Branch 33 taken 336 times.
✓ Branch 34 taken 86 times.
✓ Branch 35 taken 84 times.
✓ Branch 36 taken 152 times.
✓ Branch 37 taken 336 times.
✓ Branch 38 taken 84 times.
✓ Branch 39 taken 84 times.
✓ Branch 40 taken 84 times.
✓ Branch 41 taken 84 times.
✓ Branch 42 taken 84 times.
✓ Branch 43 taken 169 times.
✓ Branch 44 taken 168 times.
✓ Branch 45 taken 84 times.
✓ Branch 46 taken 253 times.
✓ Branch 47 taken 254 times.
✓ Branch 48 taken 340 times.
✓ Branch 49 taken 84 times.
✓ Branch 50 taken 84 times.
✓ Branch 51 taken 84 times.
✓ Branch 52 taken 84 times.
✓ Branch 53 taken 84 times.
✓ Branch 54 taken 85 times.
✓ Branch 55 taken 2368 times.
✓ Branch 56 taken 903 times.
✓ Branch 57 taken 253 times.
✓ Branch 58 taken 1047 times.
✓ Branch 59 taken 2617 times.
21760 switch(tempitem.family)
7817 {
7818 case itype_sword:
7819 {
7820 6848 tempitem.flags &= ~(ITEM_FLAG5);
7821 6848 tempitem.misc3 = 0;
7822 6848 tempitem.misc4 = 0;
7823 6848 tempitem.misc5 = 0;
7824 6848 tempitem.misc6 = 0;
7825 6848 tempitem.misc7 = 0;
7826 6848 tempitem.misc8 = 0;
7827 6848 tempitem.misc9 = 0;
7828 6848 tempitem.misc10 = 0;
7829 6848 tempitem.wpn4 = 0;
7830 6848 tempitem.wpn5 = 0;
7831 6848 tempitem.wpn6 = 0;
7832 6848 tempitem.wpn7 = 0;
7833 6848 tempitem.wpn8 = 0;
7834 6848 tempitem.wpn9 = 0;
7835 6848 tempitem.wpn10 = 0;
7836 6848 break;
7837 }
7838 case itype_brang:
7839 {
7840 253 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7841 253 tempitem.misc2 = 0;
7842 253 tempitem.misc5 = 0;
7843 253 tempitem.misc6 = 0;
7844 253 tempitem.misc7 = 0;
7845 253 tempitem.misc8 = 0;
7846 253 tempitem.misc9 = 0;
7847 253 tempitem.misc10 = 0;
7848 253 tempitem.wpn4 = 0;
7849 253 tempitem.wpn5 = 0;
7850 253 tempitem.wpn6 = 0;
7851 253 tempitem.wpn7 = 0;
7852 253 tempitem.wpn8 = 0;
7853 253 tempitem.wpn9 = 0;
7854 253 tempitem.wpn10 = 0;
7855 253 break;
7856 }
7857 case itype_arrow:
7858 {
7859 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7860 250 tempitem.misc2 = 0;
7861 250 tempitem.misc3 = 0;
7862 250 tempitem.misc4 = 0;
7863 250 tempitem.misc5 = 0;
7864 250 tempitem.misc6 = 0;
7865 250 tempitem.misc7 = 0;
7866 250 tempitem.misc8 = 0;
7867 250 tempitem.misc9 = 0;
7868 250 tempitem.misc10 = 0;
7869 250 tempitem.wpn4 = 0;
7870 250 tempitem.wpn5 = 0;
7871 250 tempitem.wpn6 = 0;
7872 250 tempitem.wpn7 = 0;
7873 250 tempitem.wpn8 = 0;
7874 250 tempitem.wpn9 = 0;
7875 250 tempitem.wpn10 = 0;
7876 250 break;
7877 }
7878 case itype_candle:
7879 {
7880 206 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7881 206 tempitem.misc1 = 0;
7882 206 tempitem.misc2 = 0;
7883 206 tempitem.misc3 = 0;
7884 206 tempitem.misc4 = 0;
7885 206 tempitem.misc5 = 0;
7886 206 tempitem.misc6 = 0;
7887 206 tempitem.misc7 = 0;
7888 206 tempitem.misc8 = 0;
7889 206 tempitem.misc9 = 0;
7890 206 tempitem.misc10 = 0;
7891 206 tempitem.wpn4 = 0;
7892 206 tempitem.wpn5 = 0;
7893 206 tempitem.wpn6 = 0;
7894 206 tempitem.wpn7 = 0;
7895 206 tempitem.wpn8 = 0;
7896 206 tempitem.wpn9 = 0;
7897 206 tempitem.wpn10 = 0;
7898 206 break;
7899 }
7900 case itype_whistle:
7901 {
7902 130 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7903 130 tempitem.misc3 = 0;
7904 130 tempitem.misc4 = 0;
7905 130 tempitem.misc5 = 0;
7906 130 tempitem.misc6 = 0;
7907 130 tempitem.misc7 = 0;
7908 130 tempitem.misc8 = 0;
7909 130 tempitem.misc9 = 0;
7910 130 tempitem.misc10 = 0;
7911 130 tempitem.wpn2 = 0;
7912 130 tempitem.wpn3 = 0;
7913 130 tempitem.wpn4 = 0;
7914 130 tempitem.wpn5 = 0;
7915 130 tempitem.wpn6 = 0;
7916 130 tempitem.wpn7 = 0;
7917 130 tempitem.wpn8 = 0;
7918 130 tempitem.wpn9 = 0;
7919 130 tempitem.wpn10 = 0;
7920 130 break;
7921 }
7922 case itype_bait:
7923 {
7924 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7925 85 tempitem.misc2 = 0;
7926 85 tempitem.misc3 = 0;
7927 85 tempitem.misc4 = 0;
7928 85 tempitem.misc5 = 0;
7929 85 tempitem.misc6 = 0;
7930 85 tempitem.misc7 = 0;
7931 85 tempitem.misc8 = 0;
7932 85 tempitem.misc9 = 0;
7933 85 tempitem.misc10 = 0;
7934 85 tempitem.wpn2 = 0;
7935 85 tempitem.wpn3 = 0;
7936 85 tempitem.wpn4 = 0;
7937 85 tempitem.wpn5 = 0;
7938 85 tempitem.wpn6 = 0;
7939 85 tempitem.wpn7 = 0;
7940 85 tempitem.wpn8 = 0;
7941 85 tempitem.wpn9 = 0;
7942 85 tempitem.wpn10 = 0;
7943 85 break;
7944 }
7945 case itype_letter:
7946 {
7947 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7948 168 tempitem.misc1 = 0;
7949 168 tempitem.misc2 = 0;
7950 168 tempitem.misc3 = 0;
7951 168 tempitem.misc4 = 0;
7952 168 tempitem.misc5 = 0;
7953 168 tempitem.misc6 = 0;
7954 168 tempitem.misc7 = 0;
7955 168 tempitem.misc8 = 0;
7956 168 tempitem.misc9 = 0;
7957 168 tempitem.misc10 = 0;
7958 168 tempitem.wpn = 0;
7959 168 tempitem.wpn2 = 0;
7960 168 tempitem.wpn3 = 0;
7961 168 tempitem.wpn4 = 0;
7962 168 tempitem.wpn5 = 0;
7963 168 tempitem.wpn6 = 0;
7964 168 tempitem.wpn7 = 0;
7965 168 tempitem.wpn8 = 0;
7966 168 tempitem.wpn9 = 0;
7967 168 tempitem.wpn10 = 0;
7968 168 break;
7969 }
7970 case itype_potion:
7971 {
7972 167 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7973 167 tempitem.misc3 = 0;
7974 167 tempitem.misc4 = 0;
7975 167 tempitem.misc5 = 0;
7976 167 tempitem.misc6 = 0;
7977 167 tempitem.misc7 = 0;
7978 167 tempitem.misc8 = 0;
7979 167 tempitem.misc9 = 0;
7980 167 tempitem.misc10 = 0;
7981 167 tempitem.wpn = 0;
7982 167 tempitem.wpn2 = 0;
7983 167 tempitem.wpn3 = 0;
7984 167 tempitem.wpn4 = 0;
7985 167 tempitem.wpn5 = 0;
7986 167 tempitem.wpn6 = 0;
7987 167 tempitem.wpn7 = 0;
7988 167 tempitem.wpn8 = 0;
7989 167 tempitem.wpn9 = 0;
7990 167 tempitem.wpn10 = 0;
7991 167 break;
7992 }
7993 case itype_wand:
7994 {
7995 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7996 99 tempitem.misc1 = 0;
7997 99 tempitem.misc2 = 0;
7998 99 tempitem.misc3 = 0;
7999 99 tempitem.misc4 = 0;
8000 99 tempitem.misc5 = 0;
8001 99 tempitem.misc6 = 0;
8002 99 tempitem.misc7 = 0;
8003 99 tempitem.misc8 = 0;
8004 99 tempitem.misc9 = 0;
8005 99 tempitem.misc10 = 0;
8006 99 tempitem.wpn4 = 0;
8007 99 tempitem.wpn5 = 0;
8008 99 tempitem.wpn6 = 0;
8009 99 tempitem.wpn7 = 0;
8010 99 tempitem.wpn8 = 0;
8011 99 tempitem.wpn9 = 0;
8012 99 tempitem.wpn10 = 0;
8013 99 break;
8014 }
8015 case itype_ring:
8016 {
8017 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8018 278 tempitem.misc2 = 0;
8019 278 tempitem.misc3 = 0;
8020 278 tempitem.misc4 = 0;
8021 278 tempitem.misc5 = 0;
8022 278 tempitem.misc6 = 0;
8023 278 tempitem.misc7 = 0;
8024 278 tempitem.misc8 = 0;
8025 278 tempitem.misc9 = 0;
8026 278 tempitem.misc10 = 0;
8027 278 tempitem.wpn = 0;
8028 278 tempitem.wpn2 = 0;
8029 278 tempitem.wpn3 = 0;
8030 278 tempitem.wpn4 = 0;
8031 278 tempitem.wpn5 = 0;
8032 278 tempitem.wpn6 = 0;
8033 278 tempitem.wpn7 = 0;
8034 278 tempitem.wpn8 = 0;
8035 278 tempitem.wpn9 = 0;
8036 278 tempitem.wpn10 = 0;
8037 278 break;
8038 }
8039 case itype_wallet:
8040 {
8041 252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8042 252 tempitem.misc3 = 0;
8043 252 tempitem.misc4 = 0;
8044 252 tempitem.misc5 = 0;
8045 252 tempitem.misc6 = 0;
8046 252 tempitem.misc7 = 0;
8047 252 tempitem.misc8 = 0;
8048 252 tempitem.misc9 = 0;
8049 252 tempitem.misc10 = 0;
8050 252 tempitem.wpn = 0;
8051 252 tempitem.wpn2 = 0;
8052 252 tempitem.wpn3 = 0;
8053 252 tempitem.wpn4 = 0;
8054 252 tempitem.wpn5 = 0;
8055 252 tempitem.wpn6 = 0;
8056 252 tempitem.wpn7 = 0;
8057 252 tempitem.wpn8 = 0;
8058 252 tempitem.wpn9 = 0;
8059 252 tempitem.wpn10 = 0;
8060 252 break;
8061 }
8062 case itype_amulet:
8063 {
8064 167 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8065 167 tempitem.misc1 = 0;
8066 167 tempitem.misc2 = 0;
8067 167 tempitem.misc3 = 0;
8068 167 tempitem.misc4 = 0;
8069 167 tempitem.misc5 = 0;
8070 167 tempitem.misc6 = 0;
8071 167 tempitem.misc7 = 0;
8072 167 tempitem.misc8 = 0;
8073 167 tempitem.misc9 = 0;
8074 167 tempitem.misc10 = 0;
8075 167 tempitem.wpn = 0;
8076 167 tempitem.wpn2 = 0;
8077 167 tempitem.wpn3 = 0;
8078 167 tempitem.wpn4 = 0;
8079 167 tempitem.wpn5 = 0;
8080 167 tempitem.wpn6 = 0;
8081 167 tempitem.wpn7 = 0;
8082 167 tempitem.wpn8 = 0;
8083 167 tempitem.wpn9 = 0;
8084 167 tempitem.wpn10 = 0;
8085 167 break;
8086 }
8087 case itype_shield:
8088 {
8089 259 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8090 259 tempitem.misc3 = 0;
8091 259 tempitem.misc4 = 0;
8092 259 tempitem.misc5 = 0;
8093 259 tempitem.misc6 = 0;
8094 259 tempitem.misc7 = 0;
8095 259 tempitem.misc8 = 0;
8096 259 tempitem.misc9 = 0;
8097 259 tempitem.misc10 = 0;
8098 259 tempitem.wpn = 0;
8099 259 tempitem.wpn2 = 0;
8100 259 tempitem.wpn3 = 0;
8101 259 tempitem.wpn4 = 0;
8102 259 tempitem.wpn5 = 0;
8103 259 tempitem.wpn6 = 0;
8104 259 tempitem.wpn7 = 0;
8105 259 tempitem.wpn8 = 0;
8106 259 tempitem.wpn9 = 0;
8107 259 tempitem.wpn10 = 0;
8108 259 break;
8109 }
8110 case itype_bow:
8111 {
8112 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8113 168 tempitem.misc1 = 0;
8114 168 tempitem.misc2 = 0;
8115 168 tempitem.misc3 = 0;
8116 168 tempitem.misc4 = 0;
8117 168 tempitem.misc5 = 0;
8118 168 tempitem.misc6 = 0;
8119 168 tempitem.misc7 = 0;
8120 168 tempitem.misc8 = 0;
8121 168 tempitem.misc9 = 0;
8122 168 tempitem.misc10 = 0;
8123 168 tempitem.wpn = 0;
8124 168 tempitem.wpn2 = 0;
8125 168 tempitem.wpn3 = 0;
8126 168 tempitem.wpn4 = 0;
8127 168 tempitem.wpn5 = 0;
8128 168 tempitem.wpn6 = 0;
8129 168 tempitem.wpn7 = 0;
8130 168 tempitem.wpn8 = 0;
8131 168 tempitem.wpn9 = 0;
8132 168 tempitem.wpn10 = 0;
8133 168 break;
8134 }
8135 case itype_raft:
8136 {
8137 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8138 84 tempitem.misc1 = 0;
8139 84 tempitem.misc2 = 0;
8140 84 tempitem.misc3 = 0;
8141 84 tempitem.misc4 = 0;
8142 84 tempitem.misc5 = 0;
8143 84 tempitem.misc6 = 0;
8144 84 tempitem.misc7 = 0;
8145 84 tempitem.misc8 = 0;
8146 84 tempitem.misc9 = 0;
8147 84 tempitem.misc10 = 0;
8148 84 tempitem.wpn = 0;
8149 84 tempitem.wpn2 = 0;
8150 84 tempitem.wpn3 = 0;
8151 84 tempitem.wpn4 = 0;
8152 84 tempitem.wpn5 = 0;
8153 84 tempitem.wpn6 = 0;
8154 84 tempitem.wpn7 = 0;
8155 84 tempitem.wpn8 = 0;
8156 84 tempitem.wpn9 = 0;
8157 84 tempitem.wpn10 = 0;
8158 84 break;
8159 }
8160 case itype_ladder:
8161 {
8162 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8163 168 tempitem.misc1 = 0;
8164 168 tempitem.misc2 = 0;
8165 168 tempitem.misc3 = 0;
8166 168 tempitem.misc4 = 0;
8167 168 tempitem.misc5 = 0;
8168 168 tempitem.misc6 = 0;
8169 168 tempitem.misc7 = 0;
8170 168 tempitem.misc8 = 0;
8171 168 tempitem.misc9 = 0;
8172 168 tempitem.misc10 = 0;
8173 168 tempitem.wpn = 0;
8174 168 tempitem.wpn2 = 0;
8175 168 tempitem.wpn3 = 0;
8176 168 tempitem.wpn4 = 0;
8177 168 tempitem.wpn5 = 0;
8178 168 tempitem.wpn6 = 0;
8179 168 tempitem.wpn7 = 0;
8180 168 tempitem.wpn8 = 0;
8181 168 tempitem.wpn9 = 0;
8182 168 tempitem.wpn10 = 0;
8183 168 break;
8184 }
8185 case itype_book:
8186 {
8187 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8188 99 tempitem.misc1 = 0;
8189 99 tempitem.misc2 = 0;
8190 99 tempitem.misc3 = 0;
8191 99 tempitem.misc4 = 0;
8192 99 tempitem.misc5 = 0;
8193 99 tempitem.misc6 = 0;
8194 99 tempitem.misc7 = 0;
8195 99 tempitem.misc8 = 0;
8196 99 tempitem.misc9 = 0;
8197 99 tempitem.misc10 = 0;
8198 99 tempitem.wpn3 = 0;
8199 99 tempitem.wpn4 = 0;
8200 99 tempitem.wpn5 = 0;
8201 99 tempitem.wpn6 = 0;
8202 99 tempitem.wpn7 = 0;
8203 99 tempitem.wpn8 = 0;
8204 99 tempitem.wpn9 = 0;
8205 99 tempitem.wpn10 = 0;
8206 99 break;
8207 }
8208 case itype_magickey:
8209 {
8210 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8211 84 tempitem.misc1 = 0;
8212 84 tempitem.misc2 = 0;
8213 84 tempitem.misc3 = 0;
8214 84 tempitem.misc4 = 0;
8215 84 tempitem.misc5 = 0;
8216 84 tempitem.misc6 = 0;
8217 84 tempitem.misc7 = 0;
8218 84 tempitem.misc8 = 0;
8219 84 tempitem.misc9 = 0;
8220 84 tempitem.misc10 = 0;
8221 84 tempitem.wpn = 0;
8222 84 tempitem.wpn2 = 0;
8223 84 tempitem.wpn3 = 0;
8224 84 tempitem.wpn4 = 0;
8225 84 tempitem.wpn5 = 0;
8226 84 tempitem.wpn6 = 0;
8227 84 tempitem.wpn7 = 0;
8228 84 tempitem.wpn8 = 0;
8229 84 tempitem.wpn9 = 0;
8230 84 tempitem.wpn10 = 0;
8231 84 break;
8232 }
8233 case itype_bracelet:
8234 {
8235 255 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8236 255 tempitem.misc1 = 0;
8237 255 tempitem.misc2 = 0;
8238 255 tempitem.misc3 = 0;
8239 255 tempitem.misc4 = 0;
8240 255 tempitem.misc5 = 0;
8241 255 tempitem.misc6 = 0;
8242 255 tempitem.misc7 = 0;
8243 255 tempitem.misc8 = 0;
8244 255 tempitem.misc9 = 0;
8245 255 tempitem.misc10 = 0;
8246 255 tempitem.wpn = 0;
8247 255 tempitem.wpn2 = 0;
8248 255 tempitem.wpn3 = 0;
8249 255 tempitem.wpn4 = 0;
8250 255 tempitem.wpn5 = 0;
8251 255 tempitem.wpn6 = 0;
8252 255 tempitem.wpn7 = 0;
8253 255 tempitem.wpn8 = 0;
8254 255 tempitem.wpn9 = 0;
8255 255 tempitem.wpn10 = 0;
8256 255 break;
8257 }
8258 case itype_flippers:
8259 {
8260 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8261 85 tempitem.misc1 = 0;
8262 85 tempitem.misc2 = 0;
8263 85 tempitem.misc3 = 0;
8264 85 tempitem.misc4 = 0;
8265 85 tempitem.misc5 = 0;
8266 85 tempitem.misc6 = 0;
8267 85 tempitem.misc7 = 0;
8268 85 tempitem.misc8 = 0;
8269 85 tempitem.misc9 = 0;
8270 85 tempitem.misc10 = 0;
8271 85 tempitem.wpn = 0;
8272 85 tempitem.wpn2 = 0;
8273 85 tempitem.wpn3 = 0;
8274 85 tempitem.wpn4 = 0;
8275 85 tempitem.wpn5 = 0;
8276 85 tempitem.wpn6 = 0;
8277 85 tempitem.wpn7 = 0;
8278 85 tempitem.wpn8 = 0;
8279 85 tempitem.wpn9 = 0;
8280 85 tempitem.wpn10 = 0;
8281 85 break;
8282 }
8283 case itype_boots:
8284 {
8285 86 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8286 86 tempitem.misc1 = 0;
8287 86 tempitem.misc2 = 0;
8288 86 tempitem.misc3 = 0;
8289 86 tempitem.misc4 = 0;
8290 86 tempitem.misc5 = 0;
8291 86 tempitem.misc6 = 0;
8292 86 tempitem.misc7 = 0;
8293 86 tempitem.misc8 = 0;
8294 86 tempitem.misc9 = 0;
8295 86 tempitem.misc10 = 0;
8296 86 tempitem.wpn = 0;
8297 86 tempitem.wpn2 = 0;
8298 86 tempitem.wpn3 = 0;
8299 86 tempitem.wpn4 = 0;
8300 86 tempitem.wpn5 = 0;
8301 86 tempitem.wpn6 = 0;
8302 86 tempitem.wpn7 = 0;
8303 86 tempitem.wpn8 = 0;
8304 86 tempitem.wpn9 = 0;
8305 86 tempitem.wpn10 = 0;
8306 86 break;
8307 }
8308 case itype_hookshot:
8309 {
8310 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8311 168 tempitem.misc5 = 0;
8312 168 tempitem.misc6 = 0;
8313 168 tempitem.misc7 = 0;
8314 168 tempitem.misc8 = 0;
8315 168 tempitem.misc9 = 0;
8316 168 tempitem.misc10 = 0;
8317 168 tempitem.wpn5 = 0;
8318 168 tempitem.wpn6 = 0;
8319 168 tempitem.wpn7 = 0;
8320 168 tempitem.wpn8 = 0;
8321 168 tempitem.wpn9 = 0;
8322 168 tempitem.wpn10 = 0;
8323 168 break;
8324 }
8325 case itype_lens:
8326 {
8327 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8328 84 tempitem.misc2 = 0;
8329 84 tempitem.misc3 = 0;
8330 84 tempitem.misc4 = 0;
8331 84 tempitem.misc5 = 0;
8332 84 tempitem.misc6 = 0;
8333 84 tempitem.misc7 = 0;
8334 84 tempitem.misc8 = 0;
8335 84 tempitem.misc9 = 0;
8336 84 tempitem.misc10 = 0;
8337 84 tempitem.wpn = 0;
8338 84 tempitem.wpn2 = 0;
8339 84 tempitem.wpn3 = 0;
8340 84 tempitem.wpn4 = 0;
8341 84 tempitem.wpn5 = 0;
8342 84 tempitem.wpn6 = 0;
8343 84 tempitem.wpn7 = 0;
8344 84 tempitem.wpn8 = 0;
8345 84 tempitem.wpn9 = 0;
8346 84 tempitem.wpn10 = 0;
8347 84 break;
8348 }
8349 case itype_hammer:
8350 {
8351 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8352 85 tempitem.misc1 = 0;
8353 85 tempitem.misc2 = 0;
8354 85 tempitem.misc3 = 0;
8355 85 tempitem.misc4 = 0;
8356 85 tempitem.misc5 = 0;
8357 85 tempitem.misc6 = 0;
8358 85 tempitem.misc7 = 0;
8359 85 tempitem.misc8 = 0;
8360 85 tempitem.misc9 = 0;
8361 85 tempitem.misc10 = 0;
8362 85 tempitem.wpn3 = 0;
8363 85 tempitem.wpn4 = 0;
8364 85 tempitem.wpn5 = 0;
8365 85 tempitem.wpn6 = 0;
8366 85 tempitem.wpn7 = 0;
8367 85 tempitem.wpn8 = 0;
8368 85 tempitem.wpn9 = 0;
8369 85 tempitem.wpn10 = 0;
8370 85 break;
8371 }
8372 case itype_divinefire:
8373 {
8374 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8375 84 tempitem.misc3 = 0;
8376 84 tempitem.misc4 = 0;
8377 84 tempitem.misc5 = 0;
8378 84 tempitem.misc6 = 0;
8379 84 tempitem.misc7 = 0;
8380 84 tempitem.misc8 = 0;
8381 84 tempitem.misc9 = 0;
8382 84 tempitem.misc10 = 0;
8383 84 tempitem.wpn6 = 0;
8384 84 tempitem.wpn7 = 0;
8385 84 tempitem.wpn8 = 0;
8386 84 tempitem.wpn9 = 0;
8387 84 tempitem.wpn10 = 0;
8388 84 break;
8389 }
8390 case itype_divineescape:
8391 {
8392 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8393 84 tempitem.misc2 = 0;
8394 84 tempitem.misc3 = 0;
8395 84 tempitem.misc4 = 0;
8396 84 tempitem.misc5 = 0;
8397 84 tempitem.misc6 = 0;
8398 84 tempitem.misc7 = 0;
8399 84 tempitem.misc8 = 0;
8400 84 tempitem.misc9 = 0;
8401 84 tempitem.misc10 = 0;
8402 84 tempitem.wpn = 0;
8403 84 tempitem.wpn2 = 0;
8404 84 tempitem.wpn3 = 0;
8405 84 tempitem.wpn4 = 0;
8406 84 tempitem.wpn5 = 0;
8407 84 tempitem.wpn6 = 0;
8408 84 tempitem.wpn7 = 0;
8409 84 tempitem.wpn8 = 0;
8410 84 tempitem.wpn9 = 0;
8411 84 tempitem.wpn10 = 0;
8412 84 break;
8413 }
8414 case itype_divineprotection:
8415 {
8416 84 tempitem.flags &= ~ (ITEM_FLAG5);
8417 84 tempitem.misc2 = 0;
8418 84 tempitem.misc3 = 0;
8419 84 tempitem.misc4 = 0;
8420 84 tempitem.misc5 = 0;
8421 84 tempitem.misc6 = 0;
8422 84 tempitem.misc7 = 0;
8423 84 tempitem.misc8 = 0;
8424 84 tempitem.misc9 = 0;
8425 84 tempitem.misc10 = 0;
8426 84 break;
8427 }
8428 case itype_bomb:
8429 {
8430 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8431 99 tempitem.misc4 = 0;
8432 99 tempitem.misc5 = 0;
8433 99 tempitem.misc6 = 0;
8434 99 tempitem.misc7 = 0;
8435 99 tempitem.misc8 = 0;
8436 99 tempitem.misc9 = 0;
8437 99 tempitem.misc10 = 0;
8438 99 tempitem.wpn3 = 0;
8439 99 tempitem.wpn4 = 0;
8440 99 tempitem.wpn5 = 0;
8441 99 tempitem.wpn6 = 0;
8442 99 tempitem.wpn7 = 0;
8443 99 tempitem.wpn8 = 0;
8444 99 tempitem.wpn9 = 0;
8445 99 tempitem.wpn10 = 0;
8446 99 break;
8447 }
8448 case itype_sbomb:
8449 {
8450 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8451 84 tempitem.misc4 = 0;
8452 84 tempitem.misc5 = 0;
8453 84 tempitem.misc6 = 0;
8454 84 tempitem.misc7 = 0;
8455 84 tempitem.misc8 = 0;
8456 84 tempitem.misc9 = 0;
8457 84 tempitem.misc10 = 0;
8458 84 tempitem.wpn3 = 0;
8459 84 tempitem.wpn4 = 0;
8460 84 tempitem.wpn5 = 0;
8461 84 tempitem.wpn6 = 0;
8462 84 tempitem.wpn7 = 0;
8463 84 tempitem.wpn8 = 0;
8464 84 tempitem.wpn9 = 0;
8465 84 tempitem.wpn10 = 0;
8466 84 break;
8467 }
8468 case itype_clock:
8469 {
8470 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8471 85 tempitem.misc2 = 0;
8472 85 tempitem.misc3 = 0;
8473 85 tempitem.misc4 = 0;
8474 85 tempitem.misc5 = 0;
8475 85 tempitem.misc6 = 0;
8476 85 tempitem.misc7 = 0;
8477 85 tempitem.misc8 = 0;
8478 85 tempitem.misc9 = 0;
8479 85 tempitem.misc10 = 0;
8480 85 tempitem.wpn = 0;
8481 85 tempitem.wpn2 = 0;
8482 85 tempitem.wpn3 = 0;
8483 85 tempitem.wpn4 = 0;
8484 85 tempitem.wpn5 = 0;
8485 85 tempitem.wpn6 = 0;
8486 85 tempitem.wpn7 = 0;
8487 85 tempitem.wpn8 = 0;
8488 85 tempitem.wpn9 = 0;
8489 85 tempitem.wpn10 = 0;
8490 85 break;
8491 }
8492 case itype_key:
8493 {
8494 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8495 84 tempitem.misc1 = 0;
8496 84 tempitem.misc2 = 0;
8497 84 tempitem.misc3 = 0;
8498 84 tempitem.misc4 = 0;
8499 84 tempitem.misc5 = 0;
8500 84 tempitem.misc6 = 0;
8501 84 tempitem.misc7 = 0;
8502 84 tempitem.misc8 = 0;
8503 84 tempitem.misc9 = 0;
8504 84 tempitem.misc10 = 0;
8505 84 tempitem.wpn = 0;
8506 84 tempitem.wpn2 = 0;
8507 84 tempitem.wpn3 = 0;
8508 84 tempitem.wpn4 = 0;
8509 84 tempitem.wpn5 = 0;
8510 84 tempitem.wpn6 = 0;
8511 84 tempitem.wpn7 = 0;
8512 84 tempitem.wpn8 = 0;
8513 84 tempitem.wpn9 = 0;
8514 84 tempitem.wpn10 = 0;
8515 84 break;
8516 }
8517 case itype_magiccontainer:
8518 {
8519 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8520 85 tempitem.misc1 = 0;
8521 85 tempitem.misc2 = 0;
8522 85 tempitem.misc3 = 0;
8523 85 tempitem.misc4 = 0;
8524 85 tempitem.misc5 = 0;
8525 85 tempitem.misc6 = 0;
8526 85 tempitem.misc7 = 0;
8527 85 tempitem.misc8 = 0;
8528 85 tempitem.misc9 = 0;
8529 85 tempitem.misc10 = 0;
8530 85 tempitem.wpn = 0;
8531 85 tempitem.wpn2 = 0;
8532 85 tempitem.wpn3 = 0;
8533 85 tempitem.wpn4 = 0;
8534 85 tempitem.wpn5 = 0;
8535 85 tempitem.wpn6 = 0;
8536 85 tempitem.wpn7 = 0;
8537 85 tempitem.wpn8 = 0;
8538 85 tempitem.wpn9 = 0;
8539 85 tempitem.wpn10 = 0;
8540 85 break;
8541 }
8542 case itype_triforcepiece:
8543 {
8544 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8545 168 tempitem.misc3 = 0;
8546 168 tempitem.misc4 = 0;
8547 168 tempitem.misc5 = 0;
8548 168 tempitem.misc6 = 0;
8549 168 tempitem.misc7 = 0;
8550 168 tempitem.misc8 = 0;
8551 168 tempitem.misc9 = 0;
8552 168 tempitem.misc10 = 0;
8553 168 tempitem.wpn = 0;
8554 168 tempitem.wpn2 = 0;
8555 168 tempitem.wpn3 = 0;
8556 168 tempitem.wpn4 = 0;
8557 168 tempitem.wpn5 = 0;
8558 168 tempitem.wpn6 = 0;
8559 168 tempitem.wpn7 = 0;
8560 168 tempitem.wpn8 = 0;
8561 168 tempitem.wpn9 = 0;
8562 168 tempitem.wpn10 = 0;
8563 168 break;
8564 }
8565 case itype_map: case itype_compass: case itype_bosskey:
8566 {
8567 253 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8568 253 tempitem.misc1 = 0;
8569 253 tempitem.misc2 = 0;
8570 253 tempitem.misc3 = 0;
8571 253 tempitem.misc4 = 0;
8572 253 tempitem.misc5 = 0;
8573 253 tempitem.misc6 = 0;
8574 253 tempitem.misc7 = 0;
8575 253 tempitem.misc8 = 0;
8576 253 tempitem.misc9 = 0;
8577 253 tempitem.misc10 = 0;
8578 253 tempitem.wpn = 0;
8579 253 tempitem.wpn2 = 0;
8580 253 tempitem.wpn3 = 0;
8581 253 tempitem.wpn4 = 0;
8582 253 tempitem.wpn5 = 0;
8583 253 tempitem.wpn6 = 0;
8584 253 tempitem.wpn7 = 0;
8585 253 tempitem.wpn8 = 0;
8586 253 tempitem.wpn9 = 0;
8587 253 tempitem.wpn10 = 0;
8588 253 break;
8589 }
8590 case itype_quiver:
8591 {
8592 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8593 336 tempitem.misc3 = 0;
8594 336 tempitem.misc4 = 0;
8595 336 tempitem.misc5 = 0;
8596 336 tempitem.misc6 = 0;
8597 336 tempitem.misc7 = 0;
8598 336 tempitem.misc8 = 0;
8599 336 tempitem.misc9 = 0;
8600 336 tempitem.misc10 = 0;
8601 336 tempitem.wpn = 0;
8602 336 tempitem.wpn2 = 0;
8603 336 tempitem.wpn3 = 0;
8604 336 tempitem.wpn4 = 0;
8605 336 tempitem.wpn5 = 0;
8606 336 tempitem.wpn6 = 0;
8607 336 tempitem.wpn7 = 0;
8608 336 tempitem.wpn8 = 0;
8609 336 tempitem.wpn9 = 0;
8610 336 tempitem.wpn10 = 0;
8611 336 break;
8612 }
8613 case itype_lkey:
8614 {
8615 86 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8616 86 tempitem.misc1 = 0;
8617 86 tempitem.misc2 = 0;
8618 86 tempitem.misc3 = 0;
8619 86 tempitem.misc4 = 0;
8620 86 tempitem.misc5 = 0;
8621 86 tempitem.misc6 = 0;
8622 86 tempitem.misc7 = 0;
8623 86 tempitem.misc8 = 0;
8624 86 tempitem.misc9 = 0;
8625 86 tempitem.misc10 = 0;
8626 86 tempitem.wpn = 0;
8627 86 tempitem.wpn2 = 0;
8628 86 tempitem.wpn3 = 0;
8629 86 tempitem.wpn4 = 0;
8630 86 tempitem.wpn5 = 0;
8631 86 tempitem.wpn6 = 0;
8632 86 tempitem.wpn7 = 0;
8633 86 tempitem.wpn8 = 0;
8634 86 tempitem.wpn9 = 0;
8635 86 tempitem.wpn10 = 0;
8636 86 break;
8637 }
8638 case itype_cbyrna:
8639 {
8640 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8641 84 tempitem.misc4 = 0;
8642 84 tempitem.misc5 = 0;
8643 84 tempitem.misc6 = 0;
8644 84 tempitem.misc7 = 0;
8645 84 tempitem.misc8 = 0;
8646 84 tempitem.misc9 = 0;
8647 84 tempitem.misc10 = 0;
8648 84 tempitem.wpn6 = 0;
8649 84 tempitem.wpn7 = 0;
8650 84 tempitem.wpn8 = 0;
8651 84 tempitem.wpn9 = 0;
8652 84 tempitem.wpn10 = 0;
8653 84 break;
8654 }
8655 case itype_rupee: case itype_arrowammo:
8656 {
8657 1047 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8658 1047 tempitem.misc1 = 0;
8659 1047 tempitem.misc2 = 0;
8660 1047 tempitem.misc3 = 0;
8661 1047 tempitem.misc4 = 0;
8662 1047 tempitem.misc5 = 0;
8663 1047 tempitem.misc6 = 0;
8664 1047 tempitem.misc7 = 0;
8665 1047 tempitem.misc8 = 0;
8666 1047 tempitem.misc9 = 0;
8667 1047 tempitem.misc10 = 0;
8668 1047 tempitem.wpn = 0;
8669 1047 tempitem.wpn2 = 0;
8670 1047 tempitem.wpn3 = 0;
8671 1047 tempitem.wpn4 = 0;
8672 1047 tempitem.wpn5 = 0;
8673 1047 tempitem.wpn6 = 0;
8674 1047 tempitem.wpn7 = 0;
8675 1047 tempitem.wpn8 = 0;
8676 1047 tempitem.wpn9 = 0;
8677 1047 tempitem.wpn10 = 0;
8678 1047 break;
8679 }
8680 case itype_fairy:
8681 {
8682 152 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8683 152 tempitem.misc4 = 0;
8684 152 tempitem.misc5 = 0;
8685 152 tempitem.misc6 = 0;
8686 152 tempitem.misc7 = 0;
8687 152 tempitem.misc8 = 0;
8688 152 tempitem.misc9 = 0;
8689 152 tempitem.misc10 = 0;
8690 152 tempitem.wpn = 0;
8691 152 tempitem.wpn2 = 0;
8692 152 tempitem.wpn3 = 0;
8693 152 tempitem.wpn4 = 0;
8694 152 tempitem.wpn5 = 0;
8695 152 tempitem.wpn6 = 0;
8696 152 tempitem.wpn7 = 0;
8697 152 tempitem.wpn8 = 0;
8698 152 tempitem.wpn9 = 0;
8699 152 tempitem.wpn10 = 0;
8700 152 break;
8701 }
8702 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8703 {
8704 903 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8705 903 tempitem.misc1 = 0;
8706 903 tempitem.misc2 = 0;
8707 903 tempitem.misc3 = 0;
8708 903 tempitem.misc4 = 0;
8709 903 tempitem.misc5 = 0;
8710 903 tempitem.misc6 = 0;
8711 903 tempitem.misc7 = 0;
8712 903 tempitem.misc8 = 0;
8713 903 tempitem.misc9 = 0;
8714 903 tempitem.misc10 = 0;
8715 903 tempitem.wpn = 0;
8716 903 tempitem.wpn2 = 0;
8717 903 tempitem.wpn3 = 0;
8718 903 tempitem.wpn4 = 0;
8719 903 tempitem.wpn5 = 0;
8720 903 tempitem.wpn6 = 0;
8721 903 tempitem.wpn7 = 0;
8722 903 tempitem.wpn8 = 0;
8723 903 tempitem.wpn9 = 0;
8724 903 tempitem.wpn10 = 0;
8725 903 break;
8726 }
8727 case itype_bombbag:
8728 {
8729 336 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8730 336 tempitem.misc3 = 0;
8731 336 tempitem.misc4 = 0;
8732 336 tempitem.misc5 = 0;
8733 336 tempitem.misc6 = 0;
8734 336 tempitem.misc7 = 0;
8735 336 tempitem.misc8 = 0;
8736 336 tempitem.misc9 = 0;
8737 336 tempitem.misc10 = 0;
8738 336 tempitem.wpn = 0;
8739 336 tempitem.wpn2 = 0;
8740 336 tempitem.wpn3 = 0;
8741 336 tempitem.wpn4 = 0;
8742 336 tempitem.wpn5 = 0;
8743 336 tempitem.wpn6 = 0;
8744 336 tempitem.wpn7 = 0;
8745 336 tempitem.wpn8 = 0;
8746 336 tempitem.wpn9 = 0;
8747 336 tempitem.wpn10 = 0;
8748 336 break;
8749 }
8750 case itype_rocs:
8751 {
8752 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8753 84 tempitem.misc1 = 0;
8754 84 tempitem.misc2 = 0;
8755 84 tempitem.misc3 = 0;
8756 84 tempitem.misc4 = 0;
8757 84 tempitem.misc5 = 0;
8758 84 tempitem.misc6 = 0;
8759 84 tempitem.misc7 = 0;
8760 84 tempitem.misc8 = 0;
8761 84 tempitem.misc9 = 0;
8762 84 tempitem.misc10 = 0;
8763 84 tempitem.wpn = 0;
8764 84 tempitem.wpn2 = 0;
8765 84 tempitem.wpn3 = 0;
8766 84 tempitem.wpn4 = 0;
8767 84 tempitem.wpn5 = 0;
8768 84 tempitem.wpn6 = 0;
8769 84 tempitem.wpn7 = 0;
8770 84 tempitem.wpn8 = 0;
8771 84 tempitem.wpn9 = 0;
8772 84 tempitem.wpn10 = 0;
8773 84 break;
8774 }
8775 case itype_hoverboots:
8776 {
8777 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8778 84 tempitem.misc2 = 0;
8779 84 tempitem.misc3 = 0;
8780 84 tempitem.misc4 = 0;
8781 84 tempitem.misc5 = 0;
8782 84 tempitem.misc6 = 0;
8783 84 tempitem.misc7 = 0;
8784 84 tempitem.misc8 = 0;
8785 84 tempitem.misc9 = 0;
8786 84 tempitem.misc10 = 0;
8787 84 tempitem.wpn2 = 0;
8788 84 tempitem.wpn3 = 0;
8789 84 tempitem.wpn4 = 0;
8790 84 tempitem.wpn5 = 0;
8791 84 tempitem.wpn6 = 0;
8792 84 tempitem.wpn7 = 0;
8793 84 tempitem.wpn8 = 0;
8794 84 tempitem.wpn9 = 0;
8795 84 tempitem.wpn10 = 0;
8796 84 break;
8797 }
8798 case itype_spinscroll:
8799 {
8800 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8801 84 tempitem.misc2 = 0;
8802 84 tempitem.misc3 = 0;
8803 84 tempitem.misc4 = 0;
8804 84 tempitem.misc5 = 0;
8805 84 tempitem.misc6 = 0;
8806 84 tempitem.misc7 = 0;
8807 84 tempitem.misc8 = 0;
8808 84 tempitem.misc9 = 0;
8809 84 tempitem.misc10 = 0;
8810 84 tempitem.wpn = 0;
8811 84 tempitem.wpn2 = 0;
8812 84 tempitem.wpn3 = 0;
8813 84 tempitem.wpn4 = 0;
8814 84 tempitem.wpn5 = 0;
8815 84 tempitem.wpn6 = 0;
8816 84 tempitem.wpn7 = 0;
8817 84 tempitem.wpn8 = 0;
8818 84 tempitem.wpn9 = 0;
8819 84 tempitem.wpn10 = 0;
8820 84 break;
8821 }
8822 case itype_crossscroll:
8823 {
8824 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8825 84 tempitem.misc1 = 0;
8826 84 tempitem.misc2 = 0;
8827 84 tempitem.misc3 = 0;
8828 84 tempitem.misc4 = 0;
8829 84 tempitem.misc5 = 0;
8830 84 tempitem.misc6 = 0;
8831 84 tempitem.misc7 = 0;
8832 84 tempitem.misc8 = 0;
8833 84 tempitem.misc9 = 0;
8834 84 tempitem.misc10 = 0;
8835 84 tempitem.wpn = 0;
8836 84 tempitem.wpn2 = 0;
8837 84 tempitem.wpn3 = 0;
8838 84 tempitem.wpn4 = 0;
8839 84 tempitem.wpn5 = 0;
8840 84 tempitem.wpn6 = 0;
8841 84 tempitem.wpn7 = 0;
8842 84 tempitem.wpn8 = 0;
8843 84 tempitem.wpn9 = 0;
8844 84 tempitem.wpn10 = 0;
8845 84 break;
8846 }
8847 case itype_quakescroll:
8848 {
8849 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8850 84 tempitem.misc3 = 0;
8851 84 tempitem.misc4 = 0;
8852 84 tempitem.misc5 = 0;
8853 84 tempitem.misc6 = 0;
8854 84 tempitem.misc7 = 0;
8855 84 tempitem.misc8 = 0;
8856 84 tempitem.misc9 = 0;
8857 84 tempitem.misc10 = 0;
8858 84 tempitem.wpn = 0;
8859 84 tempitem.wpn2 = 0;
8860 84 tempitem.wpn3 = 0;
8861 84 tempitem.wpn4 = 0;
8862 84 tempitem.wpn5 = 0;
8863 84 tempitem.wpn6 = 0;
8864 84 tempitem.wpn7 = 0;
8865 84 tempitem.wpn8 = 0;
8866 84 tempitem.wpn9 = 0;
8867 84 tempitem.wpn10 = 0;
8868 84 break;
8869 }
8870 case itype_whispring:
8871 {
8872 169 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8873 169 tempitem.misc2 = 0;
8874 169 tempitem.misc3 = 0;
8875 169 tempitem.misc4 = 0;
8876 169 tempitem.misc5 = 0;
8877 169 tempitem.misc6 = 0;
8878 169 tempitem.misc7 = 0;
8879 169 tempitem.misc8 = 0;
8880 169 tempitem.misc9 = 0;
8881 169 tempitem.misc10 = 0;
8882 169 tempitem.wpn = 0;
8883 169 tempitem.wpn2 = 0;
8884 169 tempitem.wpn3 = 0;
8885 169 tempitem.wpn4 = 0;
8886 169 tempitem.wpn5 = 0;
8887 169 tempitem.wpn6 = 0;
8888 169 tempitem.wpn7 = 0;
8889 169 tempitem.wpn8 = 0;
8890 169 tempitem.wpn9 = 0;
8891 169 tempitem.wpn10 = 0;
8892 169 break;
8893 }
8894 case itype_chargering:
8895 {
8896 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8897 168 tempitem.misc3 = 0;
8898 168 tempitem.misc4 = 0;
8899 168 tempitem.misc5 = 0;
8900 168 tempitem.misc6 = 0;
8901 168 tempitem.misc7 = 0;
8902 168 tempitem.misc8 = 0;
8903 168 tempitem.misc9 = 0;
8904 168 tempitem.misc10 = 0;
8905 168 tempitem.wpn = 0;
8906 168 tempitem.wpn2 = 0;
8907 168 tempitem.wpn3 = 0;
8908 168 tempitem.wpn4 = 0;
8909 168 tempitem.wpn5 = 0;
8910 168 tempitem.wpn6 = 0;
8911 168 tempitem.wpn7 = 0;
8912 168 tempitem.wpn8 = 0;
8913 168 tempitem.wpn9 = 0;
8914 168 tempitem.wpn10 = 0;
8915 168 break;
8916 }
8917 case itype_perilscroll:
8918 {
8919 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8920 84 tempitem.misc2 = 0;
8921 84 tempitem.misc3 = 0;
8922 84 tempitem.misc4 = 0;
8923 84 tempitem.misc5 = 0;
8924 84 tempitem.misc6 = 0;
8925 84 tempitem.misc7 = 0;
8926 84 tempitem.misc8 = 0;
8927 84 tempitem.misc9 = 0;
8928 84 tempitem.misc10 = 0;
8929 84 tempitem.wpn = 0;
8930 84 tempitem.wpn2 = 0;
8931 84 tempitem.wpn3 = 0;
8932 84 tempitem.wpn4 = 0;
8933 84 tempitem.wpn5 = 0;
8934 84 tempitem.wpn6 = 0;
8935 84 tempitem.wpn7 = 0;
8936 84 tempitem.wpn8 = 0;
8937 84 tempitem.wpn9 = 0;
8938 84 tempitem.wpn10 = 0;
8939 84 break;
8940 }
8941 case itype_wealthmedal:
8942 {
8943 253 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8944 253 tempitem.misc2 = 0;
8945 253 tempitem.misc3 = 0;
8946 253 tempitem.misc4 = 0;
8947 253 tempitem.misc5 = 0;
8948 253 tempitem.misc6 = 0;
8949 253 tempitem.misc7 = 0;
8950 253 tempitem.misc8 = 0;
8951 253 tempitem.misc9 = 0;
8952 253 tempitem.misc10 = 0;
8953 253 tempitem.wpn = 0;
8954 253 tempitem.wpn2 = 0;
8955 253 tempitem.wpn3 = 0;
8956 253 tempitem.wpn4 = 0;
8957 253 tempitem.wpn5 = 0;
8958 253 tempitem.wpn6 = 0;
8959 253 tempitem.wpn7 = 0;
8960 253 tempitem.wpn8 = 0;
8961 253 tempitem.wpn9 = 0;
8962 253 tempitem.wpn10 = 0;
8963 253 break;
8964 }
8965 case itype_heartring:
8966 {
8967 254 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8968 254 tempitem.misc3 = 0;
8969 254 tempitem.misc4 = 0;
8970 254 tempitem.misc5 = 0;
8971 254 tempitem.misc6 = 0;
8972 254 tempitem.misc7 = 0;
8973 254 tempitem.misc8 = 0;
8974 254 tempitem.misc9 = 0;
8975 254 tempitem.misc10 = 0;
8976 254 tempitem.wpn = 0;
8977 254 tempitem.wpn2 = 0;
8978 254 tempitem.wpn3 = 0;
8979 254 tempitem.wpn4 = 0;
8980 254 tempitem.wpn5 = 0;
8981 254 tempitem.wpn6 = 0;
8982 254 tempitem.wpn7 = 0;
8983 254 tempitem.wpn8 = 0;
8984 254 tempitem.wpn9 = 0;
8985 254 tempitem.wpn10 = 0;
8986 254 break;
8987 }
8988 case itype_magicring:
8989 {
8990 340 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8991 340 tempitem.misc3 = 0;
8992 340 tempitem.misc4 = 0;
8993 340 tempitem.misc5 = 0;
8994 340 tempitem.misc6 = 0;
8995 340 tempitem.misc7 = 0;
8996 340 tempitem.misc8 = 0;
8997 340 tempitem.misc9 = 0;
8998 340 tempitem.misc10 = 0;
8999 340 tempitem.wpn = 0;
9000 340 tempitem.wpn2 = 0;
9001 340 tempitem.wpn3 = 0;
9002 340 tempitem.wpn4 = 0;
9003 340 tempitem.wpn5 = 0;
9004 340 tempitem.wpn6 = 0;
9005 340 tempitem.wpn7 = 0;
9006 340 tempitem.wpn8 = 0;
9007 340 tempitem.wpn9 = 0;
9008 340 tempitem.wpn10 = 0;
9009 340 break;
9010 }
9011 case itype_spinscroll2:
9012 {
9013 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9014 84 tempitem.misc2 = 0;
9015 84 tempitem.misc3 = 0;
9016 84 tempitem.misc4 = 0;
9017 84 tempitem.misc5 = 0;
9018 84 tempitem.misc6 = 0;
9019 84 tempitem.misc7 = 0;
9020 84 tempitem.misc8 = 0;
9021 84 tempitem.misc9 = 0;
9022 84 tempitem.misc10 = 0;
9023 84 tempitem.wpn = 0;
9024 84 tempitem.wpn2 = 0;
9025 84 tempitem.wpn3 = 0;
9026 84 tempitem.wpn4 = 0;
9027 84 tempitem.wpn5 = 0;
9028 84 tempitem.wpn6 = 0;
9029 84 tempitem.wpn7 = 0;
9030 84 tempitem.wpn8 = 0;
9031 84 tempitem.wpn9 = 0;
9032 84 tempitem.wpn10 = 0;
9033 84 break;
9034 }
9035 case itype_quakescroll2:
9036 {
9037 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9038 84 tempitem.misc3 = 0;
9039 84 tempitem.misc4 = 0;
9040 84 tempitem.misc5 = 0;
9041 84 tempitem.misc6 = 0;
9042 84 tempitem.misc7 = 0;
9043 84 tempitem.misc8 = 0;
9044 84 tempitem.misc9 = 0;
9045 84 tempitem.misc10 = 0;
9046 84 tempitem.wpn = 0;
9047 84 tempitem.wpn2 = 0;
9048 84 tempitem.wpn3 = 0;
9049 84 tempitem.wpn4 = 0;
9050 84 tempitem.wpn5 = 0;
9051 84 tempitem.wpn6 = 0;
9052 84 tempitem.wpn7 = 0;
9053 84 tempitem.wpn8 = 0;
9054 84 tempitem.wpn9 = 0;
9055 84 tempitem.wpn10 = 0;
9056 84 break;
9057 }
9058 case itype_agony:
9059 {
9060 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9061 84 tempitem.misc2 = 0;
9062 84 tempitem.misc3 = 0;
9063 84 tempitem.misc4 = 0;
9064 84 tempitem.misc5 = 0;
9065 84 tempitem.misc6 = 0;
9066 84 tempitem.misc7 = 0;
9067 84 tempitem.misc8 = 0;
9068 84 tempitem.misc9 = 0;
9069 84 tempitem.misc10 = 0;
9070 84 tempitem.wpn = 0;
9071 84 tempitem.wpn2 = 0;
9072 84 tempitem.wpn3 = 0;
9073 84 tempitem.wpn4 = 0;
9074 84 tempitem.wpn5 = 0;
9075 84 tempitem.wpn6 = 0;
9076 84 tempitem.wpn7 = 0;
9077 84 tempitem.wpn8 = 0;
9078 84 tempitem.wpn9 = 0;
9079 84 tempitem.wpn10 = 0;
9080 84 break;
9081 }
9082 case itype_stompboots:
9083 {
9084 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9085 84 tempitem.misc1 = 0;
9086 84 tempitem.misc2 = 0;
9087 84 tempitem.misc3 = 0;
9088 84 tempitem.misc4 = 0;
9089 84 tempitem.misc5 = 0;
9090 84 tempitem.misc6 = 0;
9091 84 tempitem.misc7 = 0;
9092 84 tempitem.misc8 = 0;
9093 84 tempitem.misc9 = 0;
9094 84 tempitem.misc10 = 0;
9095 84 tempitem.wpn = 0;
9096 84 tempitem.wpn2 = 0;
9097 84 tempitem.wpn3 = 0;
9098 84 tempitem.wpn4 = 0;
9099 84 tempitem.wpn5 = 0;
9100 84 tempitem.wpn6 = 0;
9101 84 tempitem.wpn7 = 0;
9102 84 tempitem.wpn8 = 0;
9103 84 tempitem.wpn9 = 0;
9104 84 tempitem.wpn10 = 0;
9105 84 break;
9106 }
9107 case itype_whimsicalring:
9108 {
9109 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9110 84 tempitem.misc2 = 0;
9111 84 tempitem.misc3 = 0;
9112 84 tempitem.misc4 = 0;
9113 84 tempitem.misc5 = 0;
9114 84 tempitem.misc6 = 0;
9115 84 tempitem.misc7 = 0;
9116 84 tempitem.misc8 = 0;
9117 84 tempitem.misc9 = 0;
9118 84 tempitem.misc10 = 0;
9119 84 tempitem.wpn = 0;
9120 84 tempitem.wpn2 = 0;
9121 84 tempitem.wpn3 = 0;
9122 84 tempitem.wpn4 = 0;
9123 84 tempitem.wpn5 = 0;
9124 84 tempitem.wpn6 = 0;
9125 84 tempitem.wpn7 = 0;
9126 84 tempitem.wpn8 = 0;
9127 84 tempitem.wpn9 = 0;
9128 84 tempitem.wpn10 = 0;
9129 84 break;
9130 }
9131 case itype_perilring:
9132 {
9133 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9134 85 tempitem.misc2 = 0;
9135 85 tempitem.misc3 = 0;
9136 85 tempitem.misc4 = 0;
9137 85 tempitem.misc5 = 0;
9138 85 tempitem.misc6 = 0;
9139 85 tempitem.misc7 = 0;
9140 85 tempitem.misc8 = 0;
9141 85 tempitem.misc9 = 0;
9142 85 tempitem.misc10 = 0;
9143 85 tempitem.wpn = 0;
9144 85 tempitem.wpn2 = 0;
9145 85 tempitem.wpn3 = 0;
9146 85 tempitem.wpn4 = 0;
9147 85 tempitem.wpn5 = 0;
9148 85 tempitem.wpn6 = 0;
9149 85 tempitem.wpn7 = 0;
9150 85 tempitem.wpn8 = 0;
9151 85 tempitem.wpn9 = 0;
9152 85 tempitem.wpn10 = 0;
9153 85 break;
9154 }
9155 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9156 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9157 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9158 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9159 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9160 {
9161 2368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9162 2368 tempitem.misc1 = 0;
9163 2368 tempitem.misc2 = 0;
9164 2368 tempitem.misc3 = 0;
9165 2368 tempitem.misc4 = 0;
9166 2368 tempitem.misc5 = 0;
9167 2368 tempitem.misc6 = 0;
9168 2368 tempitem.misc7 = 0;
9169 2368 tempitem.misc8 = 0;
9170 2368 tempitem.misc9 = 0;
9171 2368 tempitem.misc10 = 0;
9172 2368 tempitem.wpn = 0;
9173 2368 tempitem.wpn2 = 0;
9174 2368 tempitem.wpn3 = 0;
9175 2368 tempitem.wpn4 = 0;
9176 2368 tempitem.wpn5 = 0;
9177 2368 tempitem.wpn6 = 0;
9178 2368 tempitem.wpn7 = 0;
9179 2368 tempitem.wpn8 = 0;
9180 2368 tempitem.wpn9 = 0;
9181 2368 tempitem.wpn10 = 0;
9182 2368 break;
9183 }
9184 }
9185 21760 }
9186 //Port quest rules to items
9187
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version <= 31)
9188 {
9189
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_bomb)
9190 {
9191
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 10 times.
99 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9192 89 else tempitem.flags &= ~ ITEM_FLAG2;
9193 99 }
9194
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21577 times.
21661 else if(tempitem.family == itype_sbomb)
9195 {
9196
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 74 times.
84 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9197 74 else tempitem.flags &= ~ ITEM_FLAG2;
9198 84 }
9199
9200
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 21324 times.
21577 else if(tempitem.family == itype_brang)
9201 {
9202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9203 253 else tempitem.flags &= ~ ITEM_FLAG4;
9204 253 }
9205
2/2
✓ Branch 0 taken 21225 times.
✓ Branch 1 taken 99 times.
21324 else if(tempitem.family == itype_wand)
9206 {
9207
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 97 times.
99 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9208 97 else tempitem.flags &= ~ ITEM_FLAG3;
9209 99 }
9210 21760 }
9211
9212 //Port quest rules to items
9213
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version <= 37)
9214 {
9215
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21675 times.
21760 if(tempitem.family == itype_flippers)
9216 {
9217
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9218 85 else tempitem.flags &= ~ ITEM_FLAG1;
9219 85 }
9220
2/2
✓ Branch 0 taken 14827 times.
✓ Branch 1 taken 6848 times.
21675 else if(tempitem.family == itype_sword)
9221 {
9222
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9223 6779 else tempitem.flags &= ~ ITEM_FLAG5;
9224 6848 }
9225
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 14728 times.
14827 else if(tempitem.family == itype_wand)
9226 {
9227
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9228 96 else tempitem.flags &= ~ ITEM_FLAG5;
9229 99 }
9230
4/4
✓ Branch 0 taken 14629 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 14423 times.
14728 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9231 {
9232 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9233
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 72 times.
305 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9234 233 else tempitem.flags &= ~ ITEM_FLAG3;
9235 305 }
9236 21760 }
9237
9238
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 38)
9239 {
9240
4/4
✓ Branch 0 taken 21507 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 21339 times.
21760 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9241 {
9242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9243 421 else tempitem.flags &= ~ITEM_FLAG4;
9244
9245
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 410 times.
421 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9246 410 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9247 421 }
9248
2/2
✓ Branch 0 taken 21089 times.
✓ Branch 1 taken 250 times.
21339 else if(tempitem.family == itype_arrow)
9249 {
9250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9251 250 else tempitem.flags &= ~ITEM_FLAG4;
9252
9253
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 246 times.
250 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9254 246 else tempitem.flags |= ITEM_FLAG2;
9255 250 }
9256 21760 }
9257
9258
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 39)
9259 {
9260
6/6
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 21577 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 21371 times.
21760 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9261 {
9262
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 377 times.
389 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9263 377 else tempitem.flags &= ~ITEM_FLAG5;
9264 389 }
9265
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 21204 times.
21371 else if(tempitem.family == itype_potion)
9266 {
9267
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 157 times.
167 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9268 {
9269 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9270 10 }
9271 else
9272 {
9273 157 tempitem.flags |= ITEM_FLAG3;
9274
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 85 times.
157 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9275 72 else tempitem.flags &= ~ITEM_FLAG4;
9276 }
9277 167 }
9278
2/2
✓ Branch 0 taken 21036 times.
✓ Branch 1 taken 168 times.
21204 else if(tempitem.family == itype_triforcepiece)
9279 {
9280
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 152 times.
168 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9281 {
9282 16 tempitem.flags |= ITEM_FLAG3;
9283
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9284 10 else tempitem.flags &= ~ITEM_FLAG4;
9285 16 }
9286 else
9287 {
9288 152 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9289 }
9290 168 }
9291 21760 }
9292
9293
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 40)
9294 {
9295
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 21397 times.
21760 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9296 {
9297
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 316 times.
363 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9298 316 else tempitem.flags &= ~ITEM_FLAG1;
9299 363 }
9300
8/8
✓ Branch 0 taken 21191 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 14343 times.
✓ Branch 3 taken 6848 times.
✓ Branch 4 taken 14244 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 84 times.
✓ Branch 7 taken 14160 times.
21397 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9301 {
9302
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7156 times.
7237 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9303 7156 else tempitem.flags &= ~ITEM_FLAG8;
9304 7237 }
9305
6/6
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
✓ Branch 2 taken 14813 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 85 times.
✓ Branch 5 taken 14728 times.
21760 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9306 {
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7032 times.
7032 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9308 7032 else tempitem.flags &= ~ITEM_FLAG7;
9309 7032 }
9310
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 84 times.
14728 else if(tempitem.family == itype_cbyrna)
9311 {
9312 84 tempitem.flags |= ITEM_FLAG7;
9313 84 }
9314 21760 }
9315
9316
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 41 )
9317 {
9318
2/2
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
21760 if(tempitem.family == itype_sword)
9319 {
9320
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9321 6779 else tempitem.flags &= ~ITEM_FLAG9;
9322
9323
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9324 6779 else tempitem.flags &= ~ITEM_FLAG10;
9325 6848 }
9326 21760 }
9327
9328
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 42 )
9329 {
9330
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_wand)
9331 {
9332
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2 times.
99 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9333 97 else tempitem.flags &= ~ITEM_FLAG3;
9334
9335 99 tempitem.flags &= ~ITEM_FLAG6;
9336 99 }
9337
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21576 times.
21661 else if(tempitem.family == itype_hammer)
9338 {
9339 85 tempitem.flags &= ~ITEM_FLAG3;
9340 85 }
9341
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21492 times.
21576 else if(tempitem.family == itype_cbyrna)
9342 {
9343 84 tempitem.flags |= ITEM_FLAG3;
9344
9345 84 tempitem.flags &= ~ITEM_FLAG6;
9346 84 }
9347
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 6848 times.
21492 else if(tempitem.family == itype_sword)
9348 {
9349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6848 times.
6848 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9350 6848 else tempitem.flags &= ~ITEM_FLAG6;
9351 6848 }
9352 21760 }
9353
9354
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 43 )
9355 {
9356
2/2
✓ Branch 0 taken 21630 times.
✓ Branch 1 taken 130 times.
21760 if(tempitem.family == itype_whistle)
9357 {
9358
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9359 127 else tempitem.flags &= ~ITEM_FLAG3;
9360 130 }
9361 21760 }
9362
9363
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 45 )
9364 {
9365
2/2
✓ Branch 0 taken 21675 times.
✓ Branch 1 taken 85 times.
21760 if(tempitem.family == itype_flippers)
9366 {
9367 85 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9368 85 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9369 85 }
9370 21760 }
9371
9372
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 46 )
9373 {
9374
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if(tempitem.family == itype_raft)
9375 {
9376 84 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9377 84 }
9378 21760 }
9379
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 34 ) //! set the default counter for older quests.
9380 {
9381
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 21686 times.
21760 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9382 {
9383 74 tempitem.cost_counter[0] = 1;
9384 74 }
9385 else
9386 {
9387
2/2
✓ Branch 0 taken 18870 times.
✓ Branch 1 taken 2816 times.
21686 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9388 2816 tempitem.cost_counter[0] = 4;
9389 else
9390 {
9391 18870 tempitem.cost_amount[0] = 0;
9392 18870 tempitem.cost_counter[0] = -1;
9393 }
9394 }
9395 21760 }
9396
9397
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 35 ) //new Lens of Truth flags
9398 {
9399
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if ( tempitem.family == itype_lens )
9400 {
9401
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 3 times.
84 if ( get_bit(quest_rules,qr_RAFTLENS) )
9402 {
9403 3 tempitem.flags |= ITEM_FLAG4;
9404 3 }
9405
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 45 times.
84 if ( get_bit(quest_rules,qr_LENSHINTS) )
9406 {
9407 45 tempitem.flags |= ITEM_FLAG1;
9408 45 }
9409
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4 times.
84 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9410 {
9411 4 tempitem.flags |= ITEM_FLAG5;
9412 4 }
9413 84 }
9414 21760 }
9415
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9416 {
9417
2/2
✓ Branch 0 taken 174080 times.
✓ Branch 1 taken 21760 times.
195840 for ( int32_t q = 0; q < 8; q++ )
9418 {
9419 174080 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9420 174080 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9421 174080 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9422 174080 tempitem.sprite_initiald[q] = 0;
9423 174080 }
9424
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 21760 times.
65280 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9425 21760 tempitem.sprite_script = 0;
9426 21760 }
9427
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9428 {
9429 21760 tempitem.pickupflag = 0;
9430 21760 }
9431
9432
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 51 )
9433 {
9434
2/2
✓ Branch 0 taken 21554 times.
✓ Branch 1 taken 206 times.
21760 if( tempitem.family == itype_candle )
9435 {
9436 206 tempitem.misc4 = 50; //Step speed
9437 206 }
9438 21760 }
9439
9440
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 52 )
9441 {
9442
2/2
✓ Branch 0 taken 21501 times.
✓ Branch 1 taken 259 times.
21760 if( tempitem.family == itype_shield )
9443 259 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9444 21760 }
9445
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if(s_version < 53)
9446 {
9447
4/4
✓ Branch 0 taken 21327 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 84 times.
21760 switch(tempitem.family)
9448 {
9449 case itype_arrow:
9450 250 tempitem.cost_counter[1] = crARROWS;
9451 250 tempitem.cost_amount[1] = 1;
9452 250 break;
9453 case itype_bomb:
9454 99 tempitem.cost_counter[1] = crBOMBS;
9455 99 tempitem.cost_amount[1] = 1;
9456 99 break;
9457 case itype_sbomb:
9458 84 tempitem.cost_counter[1] = crSBOMBS;
9459 84 tempitem.cost_amount[1] = 1;
9460 84 break;
9461 default:
9462 21327 tempitem.cost_counter[1] = crNONE;
9463 21327 tempitem.cost_amount[1] = 0;
9464 21327 }
9465 21760 tempitem.magiccosttimer[1] = 0;
9466 21760 }
9467
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23296 times.
29184 if( s_version < 54 )
9468 {
9469
2/2
✓ Branch 0 taken 23204 times.
✓ Branch 1 taken 92 times.
23296 if( tempitem.family == itype_flippers )
9470 92 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9471 23296 }
9472
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23296 times.
29184 if(s_version < 55)
9473 {
9474
3/3
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 22936 times.
23296 switch(tempitem.family)
9475 {
9476 case itype_spinscroll:
9477 case itype_quakescroll:
9478 180 tempitem.usesound2 = WAV_ZN1CHARGE;
9479 180 break;
9480 case itype_spinscroll2:
9481 case itype_quakescroll2:
9482 180 tempitem.usesound2 = WAV_ZN1CHARGE2;
9483 180 break;
9484 }
9485 23296 }
9486
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23296 times.
29184 if(s_version < 56)
9487 {
9488
4/4
✓ Branch 0 taken 22881 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 220 times.
✓ Branch 3 taken 105 times.
23296 switch(tempitem.family)
9489 {
9490 case itype_divinefire:
9491
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 6 times.
90 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9492
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 81 times.
90 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9493 90 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9494 90 break;
9495 case itype_candle:
9496
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 113 times.
220 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9497 220 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9498 220 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9499 220 break;
9500 case itype_book:
9501 105 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9502 105 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9503 105 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9504 105 break;
9505 }
9506 23296 }
9507
9508
2/2
✓ Branch 0 taken 27978 times.
✓ Branch 1 taken 1206 times.
29184 if(tempitem.fam_type==0) // Always do this
9509 1206 tempitem.fam_type=1;
9510
9511 29184 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9512 29184 }
9513 114 }
9514
9515 114 return 0;
9516 114 }
9517
9518 static bool did_init_def_items = false;
9519 59127 void init_def_items()
9520 {
9521
2/2
✓ Branch 0 taken 59089 times.
✓ Branch 1 taken 38 times.
59127 if(did_init_def_items) return;
9522 38 did_init_def_items = true;
9523 38 default_items[3].cost_counter[1] = crBOMBS;
9524 38 default_items[13].cost_counter[1] = crARROWS;
9525 38 default_items[14].cost_counter[1] = crARROWS;
9526 38 default_items[48].cost_counter[1] = crSBOMBS;
9527 38 default_items[57].cost_counter[1] = crARROWS;
9528 59127 }
9529 59127 void reset_itembuf(itemdata *item, int32_t id)
9530 {
9531 59127 init_def_items();
9532
2/2
✓ Branch 0 taken 25651 times.
✓ Branch 1 taken 33476 times.
59127 if(id<iLast)
9533 {
9534 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9535 33476 word tile = item->tile;
9536 33476 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9537 33476 int32_t ltm = item->ltm;
9538
9539 33476 memcpy(item,&default_items[id],sizeof(itemdata));
9540 33476 item->tile = tile;
9541 33476 item->misc_flags = miscs;
9542 33476 item->csets = cset;
9543 33476 item->frames = frames;
9544 33476 item->speed = speed;
9545 33476 item->delay = delay;
9546 33476 item->ltm = ltm;
9547 33476 }
9548 59127 }
9549
9550 12032 void reset_itemname(int32_t id)
9551 {
9552 12032 sprintf(item_string[id],"zz%03d",id);
9553
9554
2/2
✓ Branch 0 taken 5311 times.
✓ Branch 1 taken 6721 times.
12032 if(id < iLast)
9555 6721 strcpy(item_string[id],old_item_string[id]);
9556 12032 }
9557
9558 114 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9559 {
9560 114 word weapons_to_read=MAXWPNS;
9561 int32_t dummy;
9562 byte padding;
9563 wpndata tempweapon;
9564 114 word s_version=0, s_cversion=0;
9565
9566
9567
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x186)
9568 {
9569 weapons_to_read=64;
9570 }
9571
9572
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x185)
9573 {
9574 weapons_to_read=32;
9575 }
9576
9577
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
9578 {
9579 110 weapons_to_read=0;
9580
9581 //section version info
9582
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
9583 {
9584 return qe_invalid;
9585 }
9586
9587 110 FFCore.quest_format[vWeaponSprites] = s_version;
9588
9589 //al_trace("Weapons version %d\n", s_version);
9590
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
9591 {
9592 return qe_invalid;
9593 }
9594
9595 //section size
9596
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
9597 {
9598 return qe_invalid;
9599 }
9600
9601 //finally... section data
9602
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&weapons_to_read,f,true))
9603 {
9604 return qe_invalid;
9605 }
9606 110 }
9607
9608
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version>2)
9609 {
9610
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<weapons_to_read; i++)
9611 {
9612 char tempname[64];
9613
9614
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!pfread(tempname, 64, f, keepdata))
9615 {
9616 return qe_invalid;
9617 }
9618
9619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(keepdata)
9620 {
9621 26880 strcpy(weapon_string[i], tempname);
9622 26880 }
9623 26880 }
9624
9625
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version<4)
9626 {
9627 if(keepdata)
9628 {
9629 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9630 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9631 }
9632 }
9633
9634
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version<5)
9635 {
9636 if(keepdata)
9637 {
9638 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9639 }
9640 }
9641
9642 /*
9643 if (s_version<6)
9644 {
9645 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9646 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9647 }
9648 */
9649 105 }
9650 else
9651 {
9652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9653
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9654 2313 reset_weaponname(i);
9655 }
9656
9657
2/2
✓ Branch 0 taken 28244 times.
✓ Branch 1 taken 114 times.
28358 for(int32_t i=0; i<weapons_to_read; i++)
9658 {
9659 28244 word oldtile = 0;
9660
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 21332 times.
28244 if (s_version < 8)
9661 {
9662
1/2
✓ Branch 0 taken 21332 times.
✗ Branch 1 not taken.
21332 if (!p_igetw(&oldtile, f, true))
9663 return qe_invalid;
9664 21332 }
9665
9666
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.misc,f,true))
9667 {
9668 return qe_invalid;
9669 }
9670
9671
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.csets,f,true))
9672 {
9673 return qe_invalid;
9674 }
9675
9676
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.frames,f,true))
9677 {
9678 return qe_invalid;
9679 }
9680
9681
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.speed,f,true))
9682 {
9683 return qe_invalid;
9684 }
9685
9686
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.type,f,true))
9687 {
9688 return qe_invalid;
9689 }
9690
9691
2/2
✓ Branch 0 taken 20820 times.
✓ Branch 1 taken 7424 times.
28244 if ( s_version >= 7 )
9692 {
9693
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempweapon.script,f,true))
9694 {
9695 return qe_invalid;
9696 }
9697
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempweapon.tile,f,true))
9698 {
9699 return qe_invalid;
9700 }
9701 7424 }
9702
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 20820 times.
28244 if ( s_version < 7 )
9703 {
9704 20820 tempweapon.tile = oldtile;
9705 20820 }
9706
9707
2/2
✓ Branch 0 taken 27220 times.
✓ Branch 1 taken 1024 times.
28244 if(Header->zelda_version < 0x193)
9708 {
9709
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9710 {
9711 return qe_invalid;
9712 }
9713 1024 }
9714
9715
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 1364 times.
28244 if(s_version < 6)
9716 {
9717
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9718 {
9719 4 tempweapon.misc |= WF_BEHIND;
9720 4 }
9721 else
9722 1360 tempweapon.misc &= ~WF_BEHIND;
9723 1364 }
9724
9725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28244 times.
28244 if(keepdata==true)
9726 {
9727 28244 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9728 28244 }
9729 28244 }
9730
9731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
9732 {
9733
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<2)
9734 {
9735 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9736 9 }
9737
9738
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<5)
9739 {
9740 9 wpnsbuf[iwQuarterHearts].tile=1;
9741 9 wpnsbuf[iwQuarterHearts].csets=1;
9742 9 }
9743
9744
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x176)
9745 {
9746 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9747 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9748 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9749 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9750 }
9751
9752
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
9753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9754 {
9755 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9756 4 }
9757
9758
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if((Header->zelda_version < 0x210))
9759 {
9760 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9761 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9762 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9763 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9764 4 }
9765 114 }
9766
9767 114 return 0;
9768 114 }
9769
9770 114 void init_guys(int32_t guyversion)
9771 {
9772
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
9773 {
9774 58368 guysbuf[i] = default_guys[0];
9775 58368 }
9776
9777
2/2
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 114 times.
20292 for(int32_t i=0; i<OLDMAXGUYS; i++)
9778 {
9779 20178 guysbuf[i] = default_guys[i];
9780
2/2
✓ Branch 0 taken 19950 times.
✓ Branch 1 taken 228 times.
20178 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9781 20178 guysbuf[i].spr_death = iwDeath;
9782 20178 guysbuf[i].spr_spawn = iwSpawn;
9783 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9784
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 18585 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
20178 if(guyversion<=3 && i==ePATRABS)
9785 {
9786 9 guysbuf[i].bosspal=spDIG;
9787 9 guysbuf[i].cset=14;
9788 9 guysbuf[i].misc9=14;
9789 9 }
9790
9791
2/2
✓ Branch 0 taken 18585 times.
✓ Branch 1 taken 1593 times.
20178 if(guyversion<=3)
9792 {
9793 // Rope/Ghini Flash rules
9794
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9795 {
9796
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9797 {
9798 5 guysbuf[i].flags2 &= ~guy_flashing;
9799 5 }
9800 885 }
9801
9802
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9803 {
9804
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9805 {
9806 18 guysbuf[i].flags2 &= ~guy_flashing;
9807 18 }
9808 531 }
9809
9810
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9811 {
9812
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9813 {
9814 3 guysbuf[i].flags2 |= guy_blinking;
9815 3 }
9816
9817
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9818 {
9819 guysbuf[i].flags2 |= guy_transparent;
9820 }
9821 9 }
9822 1593 }
9823
9824 // Darknut fix
9825
10/10
✓ Branch 0 taken 20064 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 19950 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 19836 times.
✓ Branch 5 taken 114 times.
✓ Branch 6 taken 19722 times.
✓ Branch 7 taken 114 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 19608 times.
20178 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9826 {
9827
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 205 times.
570 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9828 {
9829 365 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9830 365 guysbuf[i].s_width=guysbuf[i].e_width;
9831 365 guysbuf[i].s_height=guysbuf[i].e_height;
9832 365 }
9833 205 else guysbuf[i].s_tile=860;
9834
9835
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 35 times.
570 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9836 {
9837 35 guysbuf[i].flags |= guy_bkshield;
9838 35 }
9839 570 }
9840
9841
4/4
✓ Branch 0 taken 20064 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 20170 times.
✓ Branch 3 taken 8 times.
20178 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9842 {
9843 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9844 8 }
9845 20178 }
9846 114 }
9847
9848 2304 void reset_weaponname(int32_t i)
9849 {
9850
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9851 {
9852 792 strcpy(weapon_string[i],old_weapon_string[i]);
9853 792 }
9854 else
9855 1512 sprintf(weapon_string[i],"zz%03d",i);
9856 2304 }
9857
9858 114 void init_item_drop_sets()
9859 {
9860
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9861 {
9862 // item_drop_sets[i] = default_item_drop_sets[0];
9863 29184 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9864 29184 }
9865
9866
2/2
✓ Branch 0 taken 1482 times.
✓ Branch 1 taken 114 times.
1596 for(int32_t i=0; i<isMAX; i++)
9867 {
9868 1482 item_drop_sets[i] = default_item_drop_sets[i];
9869
9870 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9871
2/2
✓ Branch 0 taken 14820 times.
✓ Branch 1 taken 1482 times.
16302 for(int32_t j=0; j<10; ++j)
9872 {
9873 14820 int32_t it = item_drop_sets[i].item[j];
9874
9875
3/4
✓ Branch 0 taken 10396 times.
✓ Branch 1 taken 4424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 666 times.
14820 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9876
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 9730 times.
10396 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9877 {
9878 666 item_drop_sets[i].chance[j+1]=0;
9879 666 }
9880
3/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 13698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 456 times.
14154 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9881 {
9882 item_drop_sets[i].chance[j+1]=0;
9883 }
9884
9885 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9886
2/2
✓ Branch 0 taken 14812 times.
✓ Branch 1 taken 8 times.
14820 if(itemsbuf[it].family == itype_misc)
9887 {
9888 // If a non-gameplay item was selected, then item drop was aborted.
9889 // Reflect this by increasing the 'Nothing' chance accordingly.
9890 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9891 8 item_drop_sets[i].chance[j+1]=0;
9892 8 }
9893 14820 }
9894 1482 }
9895 114 }
9896
9897 110 void init_favorites()
9898 {
9899
2/2
✓ Branch 0 taken 33000 times.
✓ Branch 1 taken 110 times.
33110 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9900 {
9901 33000 favorite_combos[i]=-1;
9902 33000 }
9903
9904
2/2
✓ Branch 0 taken 33000 times.
✓ Branch 1 taken 110 times.
33110 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9905 {
9906 33000 favorite_comboaliases[i]=-1;
9907 33000 }
9908 110 }
9909
9910 const char *ctype_name[cMAX]=
9911 {
9912 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9913 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9914 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9915 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9916 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9917 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9918 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9919 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9920 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9921 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9922 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9923 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9924 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9925 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9926 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9927 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9928 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9929 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9930 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9931 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9932 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9933 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9934 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9935 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9936 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9937 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9938 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9939 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9940
9941 };
9942
9943 201 int32_t init_combo_classes()
9944 {
9945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
201 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9946
2/2
✓ Branch 0 taken 36381 times.
✓ Branch 1 taken 201 times.
36582 for(int32_t i=0; i<cMAX; i++)
9947 {
9948 36381 combo_class_buf[i] = default_combo_classes[i];
9949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36381 times.
36381 if ( char const* nm = zi->getComboTypeName(i) )
9950 {
9951 36381 size_t len = strlen(nm);
9952
2/2
✓ Branch 0 taken 2328384 times.
✓ Branch 1 taken 36381 times.
2364765 for ( size_t q = 0; q < 64; q++ )
9953 {
9954
2/2
✓ Branch 0 taken 537675 times.
✓ Branch 1 taken 1790709 times.
2328384 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9955 2328384 }
9956 36381 }
9957 36381 }
9958
9959 201 return 0;
9960 }
9961
9962 89 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9963 {
9964
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 assert(v_herosprites < 6);
9965 //these are here to bypass compiler warnings about unused arguments
9966 89 cv_herosprites=cv_herosprites;
9967
9968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(keepdata)
9969 {
9970 89 zinit.hero_swim_speed=67; //default
9971 89 setupherotiles(zinit.heroAnimationStyle);
9972 89 setupherodefenses();
9973 89 setupherooffsets();
9974 89 }
9975
9976
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 76 times.
89 if(v_herosprites>=0)
9977 {
9978 word tile, tile2;
9979 byte flip, extend, dummy_byte;
9980
9981
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
9982 {
9983
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
9984 {
9985 return qe_invalid;
9986 }
9987
9988
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
9989 {
9990 return qe_invalid;
9991 }
9992
9993
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
9994 {
9995 return qe_invalid;
9996 }
9997
9998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
9999 {
10000 304 walkspr[i][spr_tile]=(int32_t)tile;
10001 304 walkspr[i][spr_flip]=(int32_t)flip;
10002 304 walkspr[i][spr_extend]=(int32_t)extend;
10003 304 }
10004 304 }
10005
10006
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10007 {
10008
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10009 {
10010 return qe_invalid;
10011 }
10012
10013
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10024 {
10025 304 stabspr[i][spr_tile]=(int32_t)tile;
10026 304 stabspr[i][spr_flip]=(int32_t)flip;
10027 304 stabspr[i][spr_extend]=(int32_t)extend;
10028 304 }
10029 304 }
10030
10031
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10032 {
10033
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10034 {
10035 return qe_invalid;
10036 }
10037
10038
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10039 {
10040 return qe_invalid;
10041 }
10042
10043
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10044 {
10045 return qe_invalid;
10046 }
10047
10048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10049 {
10050 304 slashspr[i][spr_tile]=(int32_t)tile;
10051 304 slashspr[i][spr_flip]=(int32_t)flip;
10052 304 slashspr[i][spr_extend]=(int32_t)extend;
10053 304 }
10054 304 }
10055
10056
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10057 {
10058
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10059 {
10060 return qe_invalid;
10061 }
10062
10063
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10064 {
10065 return qe_invalid;
10066 }
10067
10068
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10069 {
10070 return qe_invalid;
10071 }
10072
10073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10074 {
10075 304 floatspr[i][spr_tile]=(int32_t)tile;
10076 304 floatspr[i][spr_flip]=(int32_t)flip;
10077 304 floatspr[i][spr_extend]=(int32_t)extend;
10078 304 }
10079 304 }
10080
10081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>1)
10082 {
10083
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10084 {
10085
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10086 {
10087 return qe_invalid;
10088 }
10089
10090
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10091 {
10092 return qe_invalid;
10093 }
10094
10095
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10101 {
10102 304 swimspr[i][spr_tile]=(int32_t)tile;
10103 304 swimspr[i][spr_flip]=(int32_t)flip;
10104 304 swimspr[i][spr_extend]=(int32_t)extend;
10105 304 }
10106 304 }
10107 76 }
10108
10109
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10110 {
10111
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10112 {
10113 return qe_invalid;
10114 }
10115
10116
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10117 {
10118 return qe_invalid;
10119 }
10120
10121
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10122 {
10123 return qe_invalid;
10124 }
10125
10126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10127 {
10128 304 divespr[i][spr_tile]=(int32_t)tile;
10129 304 divespr[i][spr_flip]=(int32_t)flip;
10130 304 divespr[i][spr_extend]=(int32_t)extend;
10131 304 }
10132 304 }
10133
10134
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10135 {
10136
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10137 {
10138 return qe_invalid;
10139 }
10140
10141
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10142 {
10143 return qe_invalid;
10144 }
10145
10146
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10147 {
10148 return qe_invalid;
10149 }
10150
10151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10152 {
10153 304 poundspr[i][spr_tile]=(int32_t)tile;
10154 304 poundspr[i][spr_flip]=(int32_t)flip;
10155 304 poundspr[i][spr_extend]=(int32_t)extend;
10156 304 }
10157 304 }
10158
10159
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&tile,f,keepdata))
10160 {
10161 return qe_invalid;
10162 }
10163
10164 76 flip=0;
10165
10166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>0)
10167 {
10168
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&flip,f,keepdata))
10169 {
10170 return qe_invalid;
10171 }
10172 76 }
10173
10174
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&extend,f,keepdata))
10175 {
10176 return qe_invalid;
10177 }
10178
10179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10180 {
10181 76 castingspr[spr_tile]=(int32_t)tile;
10182 76 castingspr[spr_flip]=(int32_t)flip;
10183 76 castingspr[spr_extend]=(int32_t)extend;
10184 76 }
10185
10186
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(v_herosprites>0)
10187 {
10188 76 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10189
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 76 times.
228 for(int32_t i=0; i<2; i++)
10190 {
10191
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 152 times.
456 for(int32_t j=0; j<num_holdsprs; j++)
10192 {
10193
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10194 {
10195 return qe_invalid;
10196 }
10197
10198
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10199 {
10200 return qe_invalid;
10201 }
10202
10203
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10204 {
10205 return qe_invalid;
10206 }
10207
10208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10209 {
10210 304 holdspr[i][j][spr_tile]=(int32_t)tile;
10211 304 holdspr[i][j][spr_flip]=(int32_t)flip;
10212 304 holdspr[i][j][spr_extend]=(int32_t)extend;
10213 304 }
10214 304 }
10215 152 }
10216 76 }
10217 else
10218 {
10219 for(int32_t i=0; i<2; i++)
10220 {
10221 if(!p_igetw(&tile,f,keepdata))
10222 {
10223 return qe_invalid;
10224 }
10225
10226 if(!p_igetw(&tile2,f,keepdata))
10227 {
10228 return qe_invalid;
10229 }
10230
10231 if(!p_getc(&extend,f,keepdata))
10232 {
10233 return qe_invalid;
10234 }
10235
10236 if(keepdata)
10237 {
10238 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10239 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10240 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10241 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10242 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10243 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10244 }
10245 }
10246 }
10247
10248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>2)
10249 {
10250
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10251 {
10252
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10258 {
10259 return qe_invalid;
10260 }
10261
10262
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10263 {
10264 return qe_invalid;
10265 }
10266
10267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10268 {
10269 304 jumpspr[i][spr_tile]=(int32_t)tile;
10270 304 jumpspr[i][spr_flip]=(int32_t)flip;
10271 304 jumpspr[i][spr_extend]=(int32_t)extend;
10272 304 }
10273 304 }
10274 76 }
10275
10276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>3)
10277 {
10278
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10279 {
10280
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10281 {
10282 return qe_invalid;
10283 }
10284
10285
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10286 {
10287 return qe_invalid;
10288 }
10289
10290
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10291 {
10292 return qe_invalid;
10293 }
10294
10295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10296 {
10297 304 chargespr[i][spr_tile]=(int32_t)tile;
10298 304 chargespr[i][spr_flip]=(int32_t)flip;
10299 304 chargespr[i][spr_extend]=(int32_t)extend;
10300 304 }
10301 304 }
10302 76 }
10303
10304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>4)
10305 {
10306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!p_getc(&dummy_byte,f,keepdata))
10307 {
10308 return qe_invalid;
10309 }
10310
10311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10312 {
10313 76 zinit.hero_swim_speed=(byte)dummy_byte;
10314 76 }
10315 76 }
10316
10317
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(keepdata)
10318 {
10319 76 memset(frozenspr, 0, sizeof(frozenspr));
10320 76 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10321 76 memset(onfirespr, 0, sizeof(onfirespr));
10322 76 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10323 76 memset(diggingspr, 0, sizeof(diggingspr));
10324 76 memset(usingrodspr, 0, sizeof(usingrodspr));
10325 76 memset(usingcanespr, 0, sizeof(usingcanespr));
10326 76 memset(pushingspr, 0, sizeof(pushingspr));
10327 76 memset(liftingspr, 0, sizeof(liftingspr));
10328 76 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10329 76 memset(stunnedspr, 0, sizeof(stunnedspr));
10330 76 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10331 76 memset(fallingspr, 0, sizeof(fallingspr));
10332 76 memset(shockedspr, 0, sizeof(shockedspr));
10333 76 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10334 76 memset(pullswordspr, 0, sizeof(pullswordspr));
10335 76 memset(readingspr, 0, sizeof(readingspr));
10336 76 memset(slash180spr, 0, sizeof(slash180spr));
10337 76 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10338 76 memset(dashspr, 0, sizeof(dashspr));
10339 76 memset(bonkspr, 0, sizeof(bonkspr));
10340 76 memset(medallionsprs, 0, sizeof(medallionsprs));
10341 76 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10342 76 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10343
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t q = 0; q < 4; ++q)
10344 {
10345
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 304 times.
1216 for(int32_t p = 0; p < 3; ++p)
10346 {
10347 912 drowningspr[q][p] = divespr[q][p];
10348 912 drowning_lavaspr[q][p] = divespr[q][p];
10349 912 }
10350 304 }
10351 76 memset(sideswimspr, 0, sizeof(sideswimspr));
10352 76 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10353 76 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10354 76 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10355 76 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10356 76 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10357 76 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10358 76 }
10359 76 }
10360
10361
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
89 if(keepdata && FFCore.quest_format[vInitData] < 34)
10362 {
10363 89 bool fastswim = zinit.hero_swim_speed > 60;
10364 // '2/3' or '1/2'
10365 89 zinit.hero_swim_mult = fastswim ? 2 : 1;
10366 89 zinit.hero_swim_div = fastswim ? 3 : 2;
10367 89 }
10368 89 return 0;
10369 89 }
10370
10371 4930 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10372 {
10373 4930 arr[spr_tile] = tile;
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4930 times.
4930 arr[spr_flip] = (flip > 3 ? 0 : flip);
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4930 times.
4930 arr[spr_extend] = (ext > 2 ? 0 : ext);
10376 4930 }
10377 //Used to read the player sprites as int32_t, not word.
10378 29 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10379 {
10380 //these are here to bypass compiler warnings about unused arguments
10381 29 cv_herosprites=cv_herosprites;
10382
10383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10384 {
10385 29 zinit.hero_swim_speed=67; //default
10386 29 setupherotiles(zinit.heroAnimationStyle);
10387 29 setupherodefenses();
10388 29 setupherooffsets();
10389 29 }
10390
10391 int32_t tile, tile2;
10392 byte flip, extend, dummy_byte;
10393
10394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>=0)
10395 {
10396
10397
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10410 {
10411 return qe_invalid;
10412 }
10413
10414 116 if(keepdata)
10415 {
10416 116 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 116 }
10418 116 }
10419
10420
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10421 {
10422
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10423 {
10424 return qe_invalid;
10425 }
10426
10427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10428 {
10429 return qe_invalid;
10430 }
10431
10432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10433 {
10434 return qe_invalid;
10435 }
10436
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10438 {
10439 116 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10440 116 }
10441 116 }
10442
10443
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10444 {
10445
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10446 {
10447 return qe_invalid;
10448 }
10449
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10451 {
10452 return qe_invalid;
10453 }
10454
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10461 {
10462 116 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10463 116 }
10464 116 }
10465
10466
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10467 {
10468
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10474 {
10475 return qe_invalid;
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10479 {
10480 return qe_invalid;
10481 }
10482
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10484 {
10485 116 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10486 116 }
10487 116 }
10488
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>1)
10490 {
10491
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10492 {
10493
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10494 {
10495 return qe_invalid;
10496 }
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10499 {
10500 return qe_invalid;
10501 }
10502
10503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10504 {
10505 return qe_invalid;
10506 }
10507
10508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10509 {
10510 116 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10511 116 }
10512 116 }
10513 29 }
10514
10515
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10516 {
10517
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10518 {
10519 return qe_invalid;
10520 }
10521
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10523 {
10524 return qe_invalid;
10525 }
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10528 {
10529 return qe_invalid;
10530 }
10531
10532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10533 {
10534 116 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10535 116 }
10536 116 }
10537
10538
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10539 {
10540
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10541 {
10542 return qe_invalid;
10543 }
10544
10545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10546 {
10547 return qe_invalid;
10548 }
10549
10550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10551 {
10552 return qe_invalid;
10553 }
10554
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10556 {
10557 116 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10558 116 }
10559 116 }
10560
10561
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tile,f,keepdata))
10562 {
10563 return qe_invalid;
10564 }
10565
10566 29 flip=0;
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>0)
10569 {
10570
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&flip,f,keepdata))
10571 {
10572 return qe_invalid;
10573 }
10574 29 }
10575
10576
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&extend,f,keepdata))
10577 {
10578 return qe_invalid;
10579 }
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10582 {
10583 29 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10584 29 }
10585
10586
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(v_herosprites>0)
10587 {
10588 29 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10589
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 29 times.
87 for(int32_t i=0; i<2; i++)
10590 {
10591
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 58 times.
232 for(int32_t j=0; j<num_holdsprs; j++)
10592 {
10593
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_igetl(&tile,f,keepdata))
10594 {
10595 return qe_invalid;
10596 }
10597
10598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&flip,f,keepdata))
10599 {
10600 return qe_invalid;
10601 }
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&extend,f,keepdata))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(keepdata)
10609 {
10610 174 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10611 174 }
10612 174 }
10613 58 }
10614 29 }
10615 else
10616 {
10617 for(int32_t i=0; i<2; i++)
10618 {
10619 if(!p_igetl(&tile,f,keepdata))
10620 {
10621 return qe_invalid;
10622 }
10623
10624 if(!p_igetl(&tile2,f,keepdata))
10625 {
10626 return qe_invalid;
10627 }
10628
10629 if(!p_getc(&extend,f,keepdata))
10630 {
10631 return qe_invalid;
10632 }
10633
10634 if(keepdata)
10635 {
10636 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10637 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10638 }
10639 }
10640 }
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>2)
10643 {
10644
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10645 {
10646
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10647 {
10648 return qe_invalid;
10649 }
10650
10651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10652 {
10653 return qe_invalid;
10654 }
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10657 {
10658 return qe_invalid;
10659 }
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10662 {
10663 116 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10664 116 }
10665 116 }
10666 29 }
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>3)
10669 {
10670
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10671 {
10672
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10673 {
10674 return qe_invalid;
10675 }
10676
10677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10678 {
10679 return qe_invalid;
10680 }
10681
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10683 {
10684 return qe_invalid;
10685 }
10686
10687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10688 {
10689 116 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10690 116 }
10691 116 }
10692 29 }
10693
10694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>4)
10695 {
10696
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&dummy_byte,f,keepdata))
10697 {
10698 return qe_invalid;
10699 }
10700
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10702 {
10703 29 zinit.hero_swim_speed=(byte)dummy_byte;
10704 29 }
10705 29 }
10706
10707
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(v_herosprites>6)
10708 {
10709
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10710 {
10711
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10712 return qe_invalid;
10713
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10715 return qe_invalid;
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10718 return qe_invalid;
10719
10720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10721 {
10722 116 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10723 116 }
10724 116 }
10725
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10726 {
10727
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10728 return qe_invalid;
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10731 return qe_invalid;
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10734 return qe_invalid;
10735
10736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10737 {
10738 116 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10739 116 }
10740 116 }
10741
10742
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10743 {
10744
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10745 return qe_invalid;
10746
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10748 return qe_invalid;
10749
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10751 return qe_invalid;
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10754 {
10755 116 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10756 116 }
10757 116 }
10758
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10759 {
10760
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10761 return qe_invalid;
10762
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10764 return qe_invalid;
10765
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10767 return qe_invalid;
10768
10769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10770 {
10771 116 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10772 116 }
10773 116 }
10774
10775
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10776 {
10777
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10778 return qe_invalid;
10779
10780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10781 return qe_invalid;
10782
10783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10784 return qe_invalid;
10785
10786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10787 {
10788 116 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10789 116 }
10790 116 }
10791
10792
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10793 {
10794
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10795 return qe_invalid;
10796
10797
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10798 return qe_invalid;
10799
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10801 return qe_invalid;
10802
10803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10804 {
10805 116 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10806 116 }
10807 116 }
10808
10809
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10810 {
10811
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10812 return qe_invalid;
10813
10814
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10815 return qe_invalid;
10816
10817
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10818 return qe_invalid;
10819
10820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10821 {
10822 116 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10823 116 }
10824 116 }
10825
10826
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10827 {
10828
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10829 return qe_invalid;
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10832 return qe_invalid;
10833
10834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10835 return qe_invalid;
10836
10837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10838 {
10839 116 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10840 116 }
10841 116 }
10842
10843
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10844 {
10845
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10846 return qe_invalid;
10847
10848
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10849 return qe_invalid;
10850
10851
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10852 return qe_invalid;
10853
10854 116 byte frames = 0;
10855
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 108 times.
116 if(v_herosprites > 15)
10856 {
10857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&frames,f,keepdata))
10858 return qe_invalid;
10859 108 }
10860
10861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10862 {
10863 116 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10864 116 liftingspr[q][spr_frames] = frames;
10865 116 }
10866 116 }
10867
10868
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10869 {
10870
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10871 return qe_invalid;
10872
10873
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10874 return qe_invalid;
10875
10876
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10877 return qe_invalid;
10878
10879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10880 {
10881 116 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10882 116 }
10883 116 }
10884
10885
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10886 {
10887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&tile,f,keepdata))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10891 return qe_invalid;
10892
10893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10894 return qe_invalid;
10895
10896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10897 {
10898 116 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10899 116 }
10900 116 }
10901
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10902 {
10903
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10904 return qe_invalid;
10905
10906
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10907 return qe_invalid;
10908
10909
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10910 return qe_invalid;
10911
10912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10913 {
10914 116 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10915 116 }
10916 116 }
10917
10918
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10919 {
10920
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10921 return qe_invalid;
10922
10923
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10924 return qe_invalid;
10925
10926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10927 return qe_invalid;
10928
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10930 {
10931 116 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10932 116 }
10933 116 }
10934
10935
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10936 {
10937
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10938 return qe_invalid;
10939
10940
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10941 return qe_invalid;
10942
10943
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10944 return qe_invalid;
10945
10946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10947 {
10948 116 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10949 116 }
10950 116 }
10951
10952
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10953 {
10954
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10955 return qe_invalid;
10956
10957
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10961 return qe_invalid;
10962
10963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10964 {
10965 116 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10966 116 }
10967 116 }
10968
10969
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10970 {
10971
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10972 return qe_invalid;
10973
10974
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10978 return qe_invalid;
10979
10980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10981 {
10982 116 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10983 116 }
10984 116 }
10985
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10986 {
10987
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10988 return qe_invalid;
10989
10990
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10991 return qe_invalid;
10992
10993
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10994 return qe_invalid;
10995
10996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10997 {
10998 116 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10999 116 }
11000 116 }
11001
11002
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11003 {
11004
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11005 return qe_invalid;
11006
11007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11008 return qe_invalid;
11009
11010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11011 return qe_invalid;
11012
11013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11014 {
11015 116 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11016 116 }
11017 116 }
11018
11019
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11020 {
11021
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11022 return qe_invalid;
11023
11024
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11025 return qe_invalid;
11026
11027
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11028 return qe_invalid;
11029
11030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11031 {
11032 116 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11033 116 }
11034 116 }
11035
11036
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11037 {
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&tile,f,keepdata))
11039 return qe_invalid;
11040
11041
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11045 return qe_invalid;
11046
11047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11048 {
11049 116 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11050 116 }
11051 116 }
11052
11053
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11054 {
11055
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11056 return qe_invalid;
11057
11058
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11059 return qe_invalid;
11060
11061
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11062 return qe_invalid;
11063
11064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11065 {
11066 116 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11067 116 }
11068 116 }
11069
11070
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11071 {
11072
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11073 return qe_invalid;
11074
11075
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11076 return qe_invalid;
11077
11078
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11079 return qe_invalid;
11080
11081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11082 {
11083 116 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11084 116 }
11085 116 }
11086
11087
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11088 {
11089
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11090 return qe_invalid;
11091
11092
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11093 return qe_invalid;
11094
11095
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11099 {
11100 116 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11101 116 }
11102 116 }
11103
11104
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 29 times.
116 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11105 {
11106
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_igetl(&tile,f,keepdata))
11107 return qe_invalid;
11108
11109
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_getc(&flip,f,keepdata))
11110 return qe_invalid;
11111
11112
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_getc(&extend,f,keepdata))
11113 return qe_invalid;
11114
11115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata)
11116 {
11117 87 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11118 87 }
11119 87 }
11120 29 }
11121 else if(keepdata)
11122 {
11123 memset(frozenspr, 0, sizeof(frozenspr));
11124 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11125 memset(onfirespr, 0, sizeof(onfirespr));
11126 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11127 memset(diggingspr, 0, sizeof(diggingspr));
11128 memset(usingrodspr, 0, sizeof(usingrodspr));
11129 memset(usingcanespr, 0, sizeof(usingcanespr));
11130 memset(pushingspr, 0, sizeof(pushingspr));
11131 memset(liftingspr, 0, sizeof(liftingspr));
11132 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11133 memset(stunnedspr, 0, sizeof(stunnedspr));
11134 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11135 memset(fallingspr, 0, sizeof(fallingspr));
11136 memset(shockedspr, 0, sizeof(shockedspr));
11137 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11138 memset(pullswordspr, 0, sizeof(pullswordspr));
11139 memset(readingspr, 0, sizeof(readingspr));
11140 memset(slash180spr, 0, sizeof(slash180spr));
11141 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11142 memset(dashspr, 0, sizeof(dashspr));
11143 memset(bonkspr, 0, sizeof(bonkspr));
11144 memset(medallionsprs, 0, sizeof(medallionsprs));
11145 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11146 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11147 for(int32_t q = 0; q < 4; ++q)
11148 {
11149 for(int32_t p = 0; p < 3; ++p)
11150 {
11151 drowningspr[q][p] = divespr[q][p];
11152 drowning_lavaspr[q][p] = divespr[q][p];
11153 }
11154 }
11155 }
11156
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 8)
11157 {
11158
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11159 {
11160
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11161 return qe_invalid;
11162
11163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11164 return qe_invalid;
11165
11166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11170 {
11171 116 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11172 116 }
11173 116 }
11174 29 }
11175 else if (keepdata)
11176 {
11177 memset(sideswimspr, 0, sizeof(sideswimspr));
11178 }
11179
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 9)
11180 {
11181
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11182 {
11183
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11184 return qe_invalid;
11185
11186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11187 return qe_invalid;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11190 return qe_invalid;
11191
11192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11193 {
11194 116 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11195 116 }
11196 116 }
11197
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11198 {
11199
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11200 return qe_invalid;
11201
11202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11203 return qe_invalid;
11204
11205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11206 return qe_invalid;
11207
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11209 {
11210 116 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11211 116 }
11212 116 }
11213
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11214 {
11215
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11216 return qe_invalid;
11217
11218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11219 return qe_invalid;
11220
11221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11222 return qe_invalid;
11223
11224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11225 {
11226 116 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11227 116 }
11228 116 }
11229
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11230 {
11231
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11232 return qe_invalid;
11233
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11235 return qe_invalid;
11236
11237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11238 return qe_invalid;
11239
11240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11241 {
11242 116 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11243 116 }
11244 116 }
11245 29 }
11246 else if (keepdata)
11247 {
11248 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11249 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11250 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11251 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11252 }
11253
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 10)
11254 {
11255
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11256 {
11257 int32_t hmr;
11258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&hmr,f,keepdata))
11259 return qe_invalid;
11260
11261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11262 {
11263 116 hammeroffsets[q] = hmr;
11264 116 }
11265 116 }
11266 29 }
11267 else if (keepdata)
11268 {
11269 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11270 }
11271
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 11)
11272 {
11273
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 29 times.
116 for(int32_t q = 0; q < 3; ++q)
11274 {
11275
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_igetl(&tile,f,keepdata))
11276 return qe_invalid;
11277
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(!p_getc(&flip,f,keepdata))
11279 return qe_invalid;
11280
11281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(!p_getc(&extend,f,keepdata))
11282 return qe_invalid;
11283
11284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata)
11285 {
11286 87 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11287 87 }
11288 87 }
11289 29 }
11290 else if (keepdata)
11291 {
11292 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11293 }
11294
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 12)
11295 {
11296
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tile,f,keepdata))
11297 return qe_invalid;
11298
11299
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&flip,f,keepdata))
11300 return qe_invalid;
11301
11302
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&extend,f,keepdata))
11303 return qe_invalid;
11304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (keepdata)
11305 {
11306 29 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11307 29 }
11308
11309 29 }
11310 else if (keepdata)
11311 {
11312 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11313 }
11314
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 13)
11315 {
11316
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11317 {
11318
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11319 return qe_invalid;
11320
11321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11322 return qe_invalid;
11323
11324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11325 return qe_invalid;
11326
11327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11328 {
11329 116 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11330 116 }
11331 116 }
11332 29 }
11333 else if (keepdata)
11334 {
11335 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11336 }
11337
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 14)
11338 {
11339
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11340 {
11341
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11342 return qe_invalid;
11343
11344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11345 return qe_invalid;
11346
11347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11348 return qe_invalid;
11349
11350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11351 {
11352 116 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11353 116 }
11354 116 }
11355 29 }
11356 else if (keepdata)
11357 {
11358 memset(revslashspr, 0, sizeof(revslashspr));
11359 }
11360
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 7)
11361 {
11362 29 int32_t num_defense = wMax;
11363 29 byte def = 0;
11364
11365 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11366 /*if(v_herosprites > [x])
11367 * {
11368 * num_defense = 146 //value of wMax on version 8
11369 * }
11370 */
11371
11372
2/2
✓ Branch 0 taken 4234 times.
✓ Branch 1 taken 29 times.
4263 for (int32_t q = 0; q < num_defense; q++)
11373 {
11374
1/2
✓ Branch 0 taken 4234 times.
✗ Branch 1 not taken.
4234 if (!p_getc(&def, f, keepdata))
11375 return qe_invalid;
11376
11377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4234 times.
4234 if (keepdata)
11378 {
11379 4234 hero_defence[q] = def;
11380 4234 }
11381 4234 }
11382 29 }
11383 else if (keepdata)
11384 {
11385 int32_t num_defense = wMax;
11386 for (int32_t q = 0; q < num_defense; q++)
11387 {
11388 hero_defence[q] = 0;
11389 }
11390 }
11391 29 }
11392
11393
3/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 6 times.
29 if(keepdata && FFCore.quest_format[vInitData] < 34)
11394 {
11395 6 bool fastswim = zinit.hero_swim_speed > 60;
11396 // '2/3' or '1/2'
11397 6 zinit.hero_swim_mult = fastswim ? 2 : 1;
11398 6 zinit.hero_swim_div = fastswim ? 3 : 2;
11399 6 }
11400 29 return 0;
11401 29 }
11402
11403
11404 105 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11405 {
11406 //these are here to bypass compiler warnings about unused arguments
11407 105 Header=Header;
11408
11409 dword dummy;
11410 105 word s_version=0, s_cversion=0;
11411
11412 //section version info
11413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
11414 {
11415 return qe_invalid;
11416 }
11417
11418 105 FFCore.quest_format[vHeroSprites] = s_version;
11419
11420 //al_trace("Player sprites version %d\n", s_version);
11421
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
11422 {
11423 return qe_invalid;
11424 }
11425
11426 //section size
11427
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
11428 {
11429 return qe_invalid;
11430 }
11431
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( s_version >= 6 )
11432 {
11433 //al_trace("Reading Player Sprites v6\n");
11434 29 return readherosprites3(f, s_version, dummy, keepdata);
11435 }
11436 76 else return readherosprites2(f, s_version, dummy, keepdata);
11437 105 }
11438
11439 105 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11440 {
11441 int32_t dummy;
11442 105 word s_version=0, s_cversion=0;
11443
11444 //section version info
11445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
11446 {
11447 return qe_invalid;
11448 }
11449
11450 105 FFCore.quest_format[vSubscreen] = s_version;
11451
11452 //al_trace("Subscreens version %d\n", s_version);
11453
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
11454 {
11455 return qe_invalid;
11456 }
11457
11458 //section size
11459
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
11460 {
11461 return qe_invalid;
11462 }
11463
11464 //finally... section data
11465
2/2
✓ Branch 0 taken 13440 times.
✓ Branch 1 taken 105 times.
13545 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11466 {
11467 13440 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11468
11469
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(ret!=0) return ret;
11470 13440 }
11471
11472 105 return 0;
11473 105 }
11474
11475 13440 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11476 {
11477 13440 int32_t numsub=0;
11478 13440 byte temp_ss=0;
11479 subscreen_object temp_sub_stack;
11480 13440 subscreen_object *temp_sub = &temp_sub_stack;
11481
11482 char tempname[64];
11483
11484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(!pfread(tempname,64,f,true))
11485 {
11486 return qe_invalid;
11487 }
11488
11489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(s_version > 1)
11490 {
11491
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(!p_getc(&temp_ss,f,keepdata))
11492 {
11493 return qe_invalid;
11494 }
11495 13440 }
11496
11497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(s_version < 4)
11498 {
11499 uint8_t tmp=0;
11500
11501 if(!p_getc(&tmp,f,true))
11502 {
11503 return qe_invalid;
11504 }
11505
11506 numsub = (int32_t)tmp;
11507 }
11508 else
11509 {
11510 word tmp;
11511
11512
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(!p_igetw(&tmp, f, true))
11513 {
11514 return qe_invalid;
11515 }
11516
11517 13440 numsub = (int32_t)tmp;
11518 }
11519
11520 int32_t j;
11521
11522
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37459 times.
✓ Branch 2 taken 24019 times.
✓ Branch 3 taken 13440 times.
37459 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11523 {
11524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(keepdata)
11525 {
11526 24019 memset(temp_sub,0,sizeof(subscreen_object));
11527
11528
2/2
✓ Branch 0 taken 1199 times.
✓ Branch 1 taken 22820 times.
24019 switch(custom_subscreen[i].objects[j].type)
11529 {
11530 case ssoTEXT:
11531 case ssoTEXTBOX:
11532 case ssoCURRENTITEMTEXT:
11533 case ssoCURRENTITEMCLASSTEXT:
11534
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
1199 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11535
11536 //fall through
11537 default:
11538 24019 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11539 24019 break;
11540 }
11541 24019 }
11542
11543
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->type),f,true))
11544 {
11545 return qe_invalid;
11546 }
11547
11548
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->pos),f,keepdata))
11549 {
11550 return qe_invalid;
11551 }
11552
11553
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(s_version < 5)
11554 {
11555 switch(temp_sub->pos)
11556 {
11557 case 0:
11558 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11559 break;
11560
11561 case 1:
11562 temp_sub->pos = sspUP;
11563 break;
11564
11565 case 2:
11566 temp_sub->pos = sspDOWN;
11567 break;
11568
11569 default:
11570 temp_sub->pos = 0;
11571 }
11572 }
11573
11574
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->x),f,keepdata))
11575 {
11576 return qe_invalid;
11577 }
11578
11579
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->y),f,keepdata))
11580 {
11581 return qe_invalid;
11582 }
11583
11584
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->w),f,keepdata))
11585 {
11586 return qe_invalid;
11587 }
11588
11589
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->h),f,keepdata))
11590 {
11591 return qe_invalid;
11592 }
11593
11594
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11595 {
11596 return qe_invalid;
11597 }
11598
11599
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11600 {
11601 return qe_invalid;
11602 }
11603
11604
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11605 {
11606 return qe_invalid;
11607 }
11608
11609
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11610 {
11611 return qe_invalid;
11612 }
11613
11614
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11615 {
11616 return qe_invalid;
11617 }
11618
11619
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11620 {
11621 return qe_invalid;
11622 }
11623
11624
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11625 {
11626 return qe_invalid;
11627 }
11628
11629
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11630 {
11631 return qe_invalid;
11632 }
11633
11634
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11635 {
11636 return qe_invalid;
11637 }
11638
11639
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11640 {
11641 return qe_invalid;
11642 }
11643
11644
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11645 {
11646 return qe_invalid;
11647 }
11648
11649
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11650 {
11651 return qe_invalid;
11652 }
11653
11654
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11655 {
11656 return qe_invalid;
11657 }
11658
11659
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11660 {
11661 return qe_invalid;
11662 }
11663
11664
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11665 {
11666 return qe_invalid;
11667 }
11668
11669
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11670 {
11671 return qe_invalid;
11672 }
11673
11674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(s_version < 2)
11675 {
11676 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11677 {
11678 return qe_invalid;
11679 }
11680
11681 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11682 {
11683 return qe_invalid;
11684 }
11685
11686 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11687 {
11688 return qe_invalid;
11689 }
11690 }
11691 else
11692 {
11693
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->speed),f,keepdata))
11694 {
11695 return qe_invalid;
11696 }
11697
11698
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->delay),f,keepdata))
11699 {
11700 return qe_invalid;
11701 }
11702
11703
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11704 {
11705 return qe_invalid;
11706 }
11707 }
11708
11709 24019 int32_t temp_size=0;
11710
11711 // bool deletets = false;
11712
4/4
✓ Branch 0 taken 10119 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 11957 times.
✓ Branch 3 taken 149 times.
24019 switch(temp_sub->type)
11713 {
11714 case ssoTEXT:
11715 case ssoTEXTBOX:
11716 case ssoCURRENTITEMTEXT:
11717 case ssoCURRENTITEMCLASSTEXT:
11718 word temptempsize;
11719 /*uint8_t temp1;
11720 uint8_t temp2;
11721 temp2 = 0;
11722 if(!p_getc(&temp1,f,true))
11723 {
11724 return qe_invalid;
11725 }
11726 if(temp1)
11727 {
11728
11729 if(!p_getc(&temp2,f,true))
11730 {
11731 return qe_invalid;
11732 }
11733 }*/
11734
11735
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!p_igetw(&temptempsize,f,true))
11736 {
11737 return qe_invalid;
11738 }
11739
11740 //temptempsize = temp1 + (temp2 << 8);
11741 1794 temp_size = (int32_t)temptempsize;
11742
11743 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(keepdata)
11745 {
11746 1794 uint32_t char_length = temp_size+1;
11747 1794 temp_sub->dp1 = new char[char_length]; //memory not freed
11748
11749 //deletets = true; //obsolete
11750 1794 }
11751
11752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(temp_size)
11753 {
11754
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11755 {
11756 return qe_invalid;
11757 }
11758 1794 }
11759
11760 1794 break;
11761
11762 case ssoLIFEMETER:
11763
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11764 temp_sub->d3 = 1;
11765
11766
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11767 {
11768 return qe_invalid;
11769 }
11770
11771 149 break;
11772
11773
11774 case ssoCURRENTITEM:
11775
11776
1/2
✓ Branch 0 taken 10119 times.
✗ Branch 1 not taken.
10119 if(s_version < 6)
11777 {
11778 switch(temp_sub->d1)
11779 {
11780 case ssiBOMB:
11781 temp_sub->d1 = itype_bomb;
11782 break;
11783
11784 case ssiSWORD:
11785 temp_sub->d1 = itype_sword;
11786 break;
11787
11788 case ssiSHIELD:
11789 temp_sub->d1 = itype_shield;
11790 break;
11791
11792 case ssiCANDLE:
11793 temp_sub->d1 = itype_candle;
11794 break;
11795
11796 case ssiLETTER:
11797 temp_sub->d1 = itype_letter;
11798 break;
11799
11800 case ssiPOTION:
11801 temp_sub->d1 = itype_potion;
11802 break;
11803
11804 case ssiLETTERPOTION:
11805 temp_sub->d1 = itype_letterpotion;
11806 break;
11807
11808 case ssiBOW:
11809 temp_sub->d1 = itype_bow;
11810 break;
11811
11812 case ssiARROW:
11813 temp_sub->d1 = itype_arrow;
11814 break;
11815
11816 case ssiBOWANDARROW:
11817 temp_sub->d1 = itype_bowandarrow;
11818 break;
11819
11820 case ssiBAIT:
11821 temp_sub->d1 = itype_bait;
11822 break;
11823
11824 case ssiRING:
11825 temp_sub->d1 = itype_ring;
11826 break;
11827
11828 case ssiBRACELET:
11829 temp_sub->d1 = itype_bracelet;
11830 break;
11831
11832 case ssiMAP:
11833 temp_sub->d1 = itype_map;
11834 break;
11835
11836 case ssiCOMPASS:
11837 temp_sub->d1 = itype_compass;
11838 break;
11839
11840 case ssiBOSSKEY:
11841 temp_sub->d1 = itype_bosskey;
11842 break;
11843
11844 case ssiMAGICKEY:
11845 temp_sub->d1 = itype_magickey;
11846 break;
11847
11848 case ssiBRANG:
11849 temp_sub->d1 = itype_brang;
11850 break;
11851
11852 case ssiWAND:
11853 temp_sub->d1 = itype_wand;
11854 break;
11855
11856 case ssiRAFT:
11857 temp_sub->d1 = itype_raft;
11858 break;
11859
11860 case ssiLADDER:
11861 temp_sub->d1 = itype_ladder;
11862 break;
11863
11864 case ssiWHISTLE:
11865 temp_sub->d1 = itype_whistle;
11866 break;
11867
11868 case ssiBOOK:
11869 temp_sub->d1 = itype_book;
11870 break;
11871
11872 case ssiWALLET:
11873 temp_sub->d1 = itype_wallet;
11874 break;
11875
11876 case ssiSBOMB:
11877 temp_sub->d1 = itype_sbomb;
11878 break;
11879
11880 case ssiHCPIECE:
11881 temp_sub->d1 = itype_heartpiece;
11882 break;
11883
11884 case ssiAMULET:
11885 temp_sub->d1 = itype_amulet;
11886 break;
11887
11888 case ssiFLIPPERS:
11889 temp_sub->d1 = itype_flippers;
11890 break;
11891
11892 case ssiHOOKSHOT:
11893 temp_sub->d1 = itype_hookshot;
11894 break;
11895
11896 case ssiLENS:
11897 temp_sub->d1 = itype_lens;
11898 break;
11899
11900 case ssiHAMMER:
11901 temp_sub->d1 = itype_hammer;
11902 break;
11903
11904 case ssiBOOTS:
11905 temp_sub->d1 = itype_boots;
11906 break;
11907
11908 case ssiDIVINEFIRE:
11909 temp_sub->d1 = itype_divinefire;
11910 break;
11911
11912 case ssiDIVINEESCAPE:
11913 temp_sub->d1 = itype_divineescape;
11914 break;
11915
11916 case ssiDIVINEPROTECTION:
11917 temp_sub->d1 = itype_divineprotection;
11918 break;
11919
11920 case ssiQUIVER:
11921 temp_sub->d1 = itype_quiver;
11922 break;
11923
11924 case ssiBOMBBAG:
11925 temp_sub->d1 = itype_bombbag;
11926 break;
11927
11928 case ssiCBYRNA:
11929 temp_sub->d1 = itype_cbyrna;
11930 break;
11931
11932 case ssiROCS:
11933 temp_sub->d1 = itype_rocs;
11934 break;
11935
11936 case ssiHOVERBOOTS:
11937 temp_sub->d1 = itype_hoverboots;
11938 break;
11939
11940 case ssiSPINSCROLL:
11941 temp_sub->d1 = itype_spinscroll;
11942 break;
11943
11944 case ssiCROSSSCROLL:
11945 temp_sub->d1 = itype_crossscroll;
11946 break;
11947
11948 case ssiQUAKESCROLL:
11949 temp_sub->d1 = itype_quakescroll;
11950 break;
11951
11952 case ssiWHISPRING:
11953 temp_sub->d1 = itype_whispring;
11954 break;
11955
11956 case ssiCHARGERING:
11957 temp_sub->d1 = itype_chargering;
11958 break;
11959
11960 case ssiPERILSCROLL:
11961 temp_sub->d1 = itype_perilscroll;
11962 break;
11963
11964 case ssiWEALTHMEDAL:
11965 temp_sub->d1 = itype_wealthmedal;
11966 break;
11967
11968 case ssiHEARTRING:
11969 temp_sub->d1 = itype_heartring;
11970 break;
11971
11972 case ssiMAGICRING:
11973 temp_sub->d1 = itype_magicring;
11974 break;
11975
11976 case ssiSPINSCROLL2:
11977 temp_sub->d1 = itype_spinscroll2;
11978 break;
11979
11980 case ssiQUAKESCROLL2:
11981 temp_sub->d1 = itype_quakescroll2;
11982 break;
11983
11984 case ssiAGONY:
11985 temp_sub->d1 = itype_agony;
11986 break;
11987
11988 case ssiSTOMPBOOTS:
11989 temp_sub->d1 = itype_stompboots;
11990 break;
11991
11992 case ssiWHIMSICALRING:
11993 temp_sub->d1 = itype_whimsicalring;
11994 break;
11995
11996 case ssiPERILRING:
11997 temp_sub->d1 = itype_perilring;
11998 break;
11999
12000 default:
12001 temp_sub->d1 += itype_custom1 - ssiMAX;
12002 }
12003 }
12004
12005 //fall-through
12006 default:
12007
1/2
✓ Branch 0 taken 22076 times.
✗ Branch 1 not taken.
22076 if(!p_getc(&(temp_sub->dp1),f,keepdata))
12008 {
12009 return qe_invalid;
12010 }
12011
12012 22076 break;
12013 }
12014
12015
2/2
✓ Branch 0 taken 15419 times.
✓ Branch 1 taken 8600 times.
24019 if(s_version < 7)
12016 {
12017
3/3
✓ Branch 0 taken 7941 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8600 switch(temp_sub->type)
12018 {
12019 case ssoMAGICGAUGE:
12020 {
12021
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
12022 192 temp_sub->d9 = -1; //-1 now represents 'always'
12023 227 break;
12024 }
12025 case ssoLIFEGAUGE:
12026 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12027 432 break;
12028 }
12029 8600 }
12030
12031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(keepdata)
12032 {
12033
3/3
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 21168 times.
✓ Branch 2 taken 1057 times.
24019 switch(temp_sub->type)
12034 {
12035 case ssoTEXT:
12036 case ssoTEXTBOX:
12037 case ssoCURRENTITEMTEXT:
12038 case ssoCURRENTITEMCLASSTEXT:
12039
1/4
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
12040
12041 1794 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12042 1794 custom_subscreen[i].objects[j].dp1 = NULL;
12043 1794 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
12044 1794 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
12045 1794 break;
12046
12047 case ssoCOUNTER:
12048
1/2
✓ Branch 0 taken 1057 times.
✗ Branch 1 not taken.
1057 if(s_version<3)
12049 {
12050 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12051 temp_sub->d8=0;
12052 }
12053
12054 default:
12055 22225 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12056 22225 break;
12057 }
12058
12059 24019 strcpy(custom_subscreen[i].name, tempname);
12060 24019 custom_subscreen[i].ss_type = temp_ss;
12061 24019 }
12062 24019 }
12063
12064
2/2
✓ Branch 0 taken 3416621 times.
✓ Branch 1 taken 13440 times.
3430061 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12065 {
12066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3416621 times.
3416621 if(keepdata)
12067 {
12068 //clear all unused object in this subscreen -DD
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3416621 times.
3416621 switch(custom_subscreen[i].objects[j].type)
12070 {
12071 case ssoTEXT:
12072 case ssoTEXTBOX:
12073 case ssoCURRENTITEMTEXT:
12074 case ssoCURRENTITEMCLASSTEXT:
12075 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12076
12077 //fall through
12078 default:
12079 3416621 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12080 3416621 break;
12081 }
12082 3416621 }
12083 3416621 }
12084
12085 13440 return 0;
12086 13440 }
12087
12088 2944 void reset_subscreen(subscreen_group *tempss)
12089 {
12090
2/2
✓ Branch 0 taken 753664 times.
✓ Branch 1 taken 2944 times.
756608 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12091 {
12092
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 753522 times.
753664 switch(tempss->objects[i].type)
12093 {
12094 case ssoTEXT:
12095 case ssoTEXTBOX:
12096 case ssoCURRENTITEMTEXT:
12097 case ssoCURRENTITEMCLASSTEXT:
12098
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12099
12100 //fall through
12101 default:
12102 753664 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12103 753664 break;
12104 }
12105 753664 }
12106 2944 }
12107
12108 23 void reset_subscreens()
12109 {
12110
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 23 times.
2967 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12111 {
12112 2944 reset_subscreen(&custom_subscreen[i]);
12113 2944 }
12114 23 }
12115
12116 23 int32_t setupsubscreens()
12117 {
12118 23 reset_subscreens();
12119 23 int32_t tempsubscreen=zinit.subscreen;
12120 subscreen_object *tempsub;
12121
12122
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tempsubscreen>=ssdtMAX)
12123 {
12124 tempsubscreen=0;
12125 }
12126
12127
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 switch(tempsubscreen)
12128 {
12129 case ssdtOLD:
12130 case ssdtNEWSUBSCR:
12131 case ssdtREV2:
12132 case ssdtBSZELDA:
12133 case ssdtBSZELDAMODIFIED:
12134 case ssdtBSZELDAENHANCED:
12135 case ssdtBSZELDACOMPLETE:
12136 {
12137 23 tempsub = default_subscreen_active[tempsubscreen][0];
12138 int32_t i;
12139
12140
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12141 {
12142
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1431 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12143 {
12144 case ssoTEXT:
12145 case ssoTEXTBOX:
12146 case ssoCURRENTITEMTEXT:
12147 case ssoCURRENTITEMCLASSTEXT:
12148
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12149
12150 64 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12151 64 custom_subscreen[0].objects[i].dp1 = NULL;
12152 64 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12153 64 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12154 64 break;
12155
12156 case ssoLIFEMETER:
12157 {
12158 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12159
12160 if(get_bit(deprecated_rules, 12) != 0)
12161 custom_subscreen[0].objects[i].d3=1;
12162 else
12163 custom_subscreen[0].objects[i].d3=0;
12164
12165 break;
12166 }
12167 /*
12168 case ssoTRIFRAME:
12169 {
12170 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12171 custom_subscreen[0].objects[i].d1 = 8594;
12172 custom_subscreen[0].objects[i].d2 = 8;
12173 custom_subscreen[0].objects[i].d3 = 8771;
12174 custom_subscreen[0].objects[i].d4 = 8;
12175 custom_subscreen[0].objects[i].d5 = 1;
12176 custom_subscreen[0].objects[i].d6 = 1;
12177 break;
12178 }*/
12179
12180 default:
12181 1431 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12182 1431 break;
12183 }
12184 1495 }
12185
12186 23 custom_subscreen[0].ss_type=sstACTIVE;
12187 23 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12188 23 tempsub = default_subscreen_active[tempsubscreen][1];
12189
12190
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12191 {
12192
2/3
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1412 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12193 {
12194 case ssoTEXT:
12195 case ssoTEXTBOX:
12196 case ssoCURRENTITEMTEXT:
12197 case ssoCURRENTITEMCLASSTEXT:
12198
1/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12199
12200 83 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12201 83 custom_subscreen[1].objects[i].dp1 = NULL;
12202 83 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12203 83 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12204 83 break;
12205
12206 case ssoLIFEMETER:
12207 {
12208 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12209
12210 if(get_bit(deprecated_rules, 12) != 0)
12211 custom_subscreen[1].objects[i].d3=1;
12212 else
12213 custom_subscreen[1].objects[i].d3=0;
12214
12215 break;
12216 }
12217 /*
12218 case ssoTRIFRAME:
12219 {
12220 custom_subscreen[1].objects[i].d1 = 8594;
12221 custom_subscreen[1].objects[i].d2 = 8;
12222 custom_subscreen[1].objects[i].d3 = 8771;
12223 custom_subscreen[1].objects[i].d4 = 8;
12224 custom_subscreen[1].objects[i].d5 = 1;
12225 custom_subscreen[1].objects[i].d6 = 1;
12226 break;
12227 }*/
12228
12229 default:
12230 1412 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12231 1412 break;
12232 }
12233 1495 }
12234
12235 23 custom_subscreen[1].ss_type=sstACTIVE;
12236 23 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12237 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12238 23 tempsub = default_subscreen_passive[tempsubscreen][0];
12239
12240
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 23 times.
483 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12241 {
12242
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 23 times.
460 switch(tempsub[i].type)
12243 {
12244 case ssoTEXT:
12245 case ssoTEXTBOX:
12246 case ssoCURRENTITEMTEXT:
12247 case ssoCURRENTITEMCLASSTEXT:
12248
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12249
12250 69 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12251 69 custom_subscreen[2].objects[i].dp1 = NULL;
12252 69 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12253 69 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12254 69 break;
12255
12256 case ssoLIFEMETER:
12257 {
12258 23 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12259
12260
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12261 7 custom_subscreen[2].objects[i].d3=1;
12262 else
12263 16 custom_subscreen[2].objects[i].d3=0;
12264
12265 23 break;
12266 }
12267
12268 default:
12269 368 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12270 368 break;
12271 }
12272 460 }
12273
12274 23 custom_subscreen[2].ss_type=sstPASSIVE;
12275 23 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12276 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12277 23 tempsub = default_subscreen_passive[tempsubscreen][1];
12278
12279
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 23 times.
460 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12280 {
12281
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 23 times.
437 switch(tempsub[i].type)
12282 {
12283 case ssoTEXT:
12284 case ssoTEXTBOX:
12285 case ssoCURRENTITEMTEXT:
12286 case ssoCURRENTITEMCLASSTEXT:
12287
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12288
12289 69 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12290 69 custom_subscreen[3].objects[i].dp1 = NULL;
12291 69 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12292 69 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12293 69 break;
12294
12295 case ssoLIFEMETER:
12296 {
12297 23 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12298
12299
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12300 7 custom_subscreen[3].objects[i].d3=1;
12301 else
12302 16 custom_subscreen[3].objects[i].d3=0;
12303
12304 23 break;
12305 }
12306
12307 default:
12308 345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12309 345 break;
12310 }
12311 437 }
12312
12313 23 custom_subscreen[3].ss_type=sstPASSIVE;
12314 23 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12315 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12316 23 break;
12317 }
12318
12319 case ssdtZ3:
12320 {
12321 tempsub = z3_active_a;
12322 int32_t i;
12323
12324 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12325 {
12326 switch(tempsub[i].type)
12327 {
12328 case ssoTEXT:
12329 case ssoTEXTBOX:
12330 case ssoCURRENTITEMTEXT:
12331 case ssoCURRENTITEMCLASSTEXT:
12332 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12333
12334 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12335 custom_subscreen[0].objects[i].dp1 = NULL;
12336 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12337 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12338 break;
12339
12340 case ssoLIFEMETER:
12341 {
12342 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12343
12344 if(get_bit(deprecated_rules, 12) != 0)
12345 custom_subscreen[0].objects[i].d3=1;
12346 else
12347 custom_subscreen[0].objects[i].d3=0;
12348
12349 break;
12350 }
12351
12352 default:
12353 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12354 break;
12355 }
12356 }
12357
12358 custom_subscreen[0].ss_type=sstACTIVE;
12359 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12360 tempsub = z3_active_ab;
12361
12362 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12363 {
12364 switch(tempsub[i].type)
12365 {
12366 case ssoTEXT:
12367 case ssoTEXTBOX:
12368 case ssoCURRENTITEMTEXT:
12369 case ssoCURRENTITEMCLASSTEXT:
12370 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12371
12372 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12373 custom_subscreen[1].objects[i].dp1 = NULL;
12374 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12375 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12376 break;
12377
12378 case ssoLIFEMETER:
12379 {
12380 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12381
12382 if(get_bit(deprecated_rules, 12) != 0)
12383 custom_subscreen[1].objects[i].d3=1;
12384 else
12385 custom_subscreen[1].objects[i].d3=0;
12386
12387 break;
12388 }
12389
12390 default:
12391 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12392 break;
12393 }
12394 }
12395
12396 custom_subscreen[1].ss_type=sstACTIVE;
12397 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12398 tempsub = z3_passive_a;
12399
12400 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12401 {
12402 switch(tempsub[i].type)
12403 {
12404 case ssoTEXT:
12405 case ssoTEXTBOX:
12406 case ssoCURRENTITEMTEXT:
12407 case ssoCURRENTITEMCLASSTEXT:
12408 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12409
12410 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12411 custom_subscreen[2].objects[i].dp1 = NULL;
12412 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12413 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12414 break;
12415
12416 case ssoLIFEMETER:
12417 {
12418 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12419
12420 if(get_bit(deprecated_rules, 12) != 0)
12421 custom_subscreen[2].objects[i].d3=1;
12422 else
12423 custom_subscreen[2].objects[i].d3=0;
12424
12425 break;
12426 }
12427
12428 default:
12429 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12430 break;
12431 }
12432 }
12433
12434 custom_subscreen[2].ss_type=sstPASSIVE;
12435 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12436 tempsub = z3_passive_ab;
12437
12438 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12439 {
12440 switch(tempsub[i].type)
12441 {
12442 case ssoTEXT:
12443 case ssoTEXTBOX:
12444 case ssoCURRENTITEMTEXT:
12445 case ssoCURRENTITEMCLASSTEXT:
12446 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12447
12448 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12449 custom_subscreen[3].objects[i].dp1 = NULL;
12450 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12451 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12452 break;
12453
12454 case ssoLIFEMETER:
12455 {
12456 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12457
12458 if(get_bit(deprecated_rules, 12) != 0)
12459 custom_subscreen[3].objects[i].d3=1;
12460 else
12461 custom_subscreen[3].objects[i].d3=0;
12462
12463 break;
12464 }
12465
12466 default:
12467 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12468 break;
12469 }
12470 }
12471
12472 custom_subscreen[3].ss_type=sstPASSIVE;
12473 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12474 break;
12475 }
12476 }
12477
12478
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 92 times.
115 for(int32_t i=0; i<4; ++i)
12479 {
12480 92 purge_blank_subscreen_objects(&custom_subscreen[i]);
12481 92 }
12482
12483 23 return 0;
12484 }
12485
12486 extern script_data *ffscripts[NUMSCRIPTFFC];
12487 extern script_data *itemscripts[NUMSCRIPTITEM];
12488 extern script_data *guyscripts[NUMSCRIPTGUYS];
12489 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12490 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12491 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12492 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12493 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12494 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12495 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12496 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12497 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12498 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12499 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12500
12501
12502
12503 105 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12504 {
12505 int32_t dummy;
12506 105 word s_version=0, s_cversion=0, zmeta_version=0;
12507 105 byte numscripts=0;
12508 105 numscripts=numscripts; //to avoid unused variables warnings
12509 int32_t ret;
12510
12511 //section version info
12512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
12513 {
12514 return qe_invalid;
12515 }
12516
12517 105 FFCore.quest_format[vFFScript] = s_version;
12518
12519
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
12520 {
12521 return qe_invalid;
12522 }
12523
12524
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 18)
12525 {
12526
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&zmeta_version,f,true))
12527 {
12528 return qe_invalid;
12529 }
12530 29 }
12531
12532 //al_trace("Scripts version %d\n", s_version);
12533 //section size
12534
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
12535 {
12536 return qe_invalid;
12537 }
12538
12539 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12540 105 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12541 105 temp_ffscript_version = s_version;
12542 //miscQdata *the_misc;
12543
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12544 105 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12545
12546 //finally... section data
12547
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12548 {
12549 53760 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12550
12551
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(ret != 0) return qe_invalid;
12552 53760 }
12553
12554 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12555 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12556 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12557 * there was a version bump a week before a change that broke stuff.
12558 */
12559
6/8
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 76 times.
105 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12560 {
12561 76 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12562 76 }
12563
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
105 if(s_version < 19 && keepdata)
12564 {
12565 76 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12566 76 }
12567
12568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 1)
12569 {
12570
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12571 {
12572 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12573
12574
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12575 26880 }
12576
12577
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12578 {
12579 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12580
12581
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12582 26880 }
12583
12584
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12585 {
12586 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12587
12588
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12589 26880 }
12590
12591
12592
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12593 {
12594 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12595
12596
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12597 26880 }
12598
12599
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version > 16)
12600 {
12601
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 29 times.
261 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12602 {
12603 232 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12604
12605
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(ret != 0) return qe_invalid;
12606 232 }
12607 29 }
12608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 else if(s_version > 13)
12609 {
12610 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12611 {
12612 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12613
12614 if(ret != 0) return qe_invalid;
12615 }
12616
12617 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12618 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12619
12620 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12621 }
12622
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 else if(s_version > 4)
12623 {
12624
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12625 {
12626 304 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12627
12628
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(ret != 0) return qe_invalid;
12629 304 }
12630
12631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12632
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12633
12634
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12635
12636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12637
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12638
12639
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12640
12641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12642
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_F6];
12643
12644
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12645
12646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12647
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12648
12649
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12650 76 }
12651 else
12652 {
12653 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12654 {
12655 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12656
12657 if(ret != 0) return qe_invalid;
12658 }
12659
12660 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12661 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12662
12663 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12664
12665 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12666 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12667
12668 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12669
12670 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12671 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12672
12673 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12674
12675 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12676 delete globalscripts[GLOBAL_SCRIPT_F6];
12677
12678 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12679
12680 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12681 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12682
12683 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12684 }
12685
12686
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version > 10) //expanded the number of Player scripts to 5.
12687 {
12688
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 29 times.
174 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12689 {
12690 145 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12691
12692
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(ret != 0) return qe_invalid;
12693 145 }
12694 29 }
12695 else
12696 {
12697
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 76 times.
304 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12698 {
12699 228 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12700
12701
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(ret != 0) return qe_invalid;
12702 228 }
12703
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[3] != NULL)
12704
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete playerscripts[3];
12705
12706
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[3] = new script_data();
12707
12708
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[4] != NULL)
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 delete playerscripts[4];
12710
12711
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[4] = new script_data();
12712 }
12713
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
105 if(s_version > 8 && s_version < 10)
12714 {
12715
12716 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12717 {
12718 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12719
12720 if(ret != 0) return qe_invalid;
12721 }
12722 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12723 {
12724 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12725
12726 if(ret != 0) return qe_invalid;
12727 }
12728
12729 }
12730
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 10)
12731 {
12732
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12733 {
12734 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12735
12736
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12737 7424 }
12738
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12739 {
12740 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12741
12742
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12743 7424 }
12744
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12745 {
12746 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12747
12748
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12749 7424 }
12750
12751 29 }
12752
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >=12)
12753 {
12754
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12755 {
12756 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12757
12758
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12759 7424 }
12760 29 }
12761
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >=15)
12762 {
12763
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12764 {
12765 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12766
12767
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12768 14848 }
12769 29 }
12770
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >19)
12771 {
12772 29 word numgenscripts = NUMSCRIPTSGENERIC;
12773
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&numgenscripts,f,true))
12774 {
12775 return qe_invalid;
12776 }
12777
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int32_t i = 0; i < numgenscripts; i++)
12778 {
12779 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12780
12781
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12782 14848 }
12783 29 }
12784
12785 /*
12786 else //Is this trip really necessary?
12787 {
12788 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12789 {
12790
12791 ewpnscripts[i] = NULL;
12792 }
12793 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12794 {
12795 dmapscripts[i] = NULL;
12796 }
12797 }
12798 */
12799
12800 105 }
12801
12802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 2)
12803 {
12804 int32_t bufsize;
12805 105 p_igetl(&bufsize, f, true);
12806 105 char * buf = new char[bufsize+1];
12807 105 pfread(buf, bufsize, f, true);
12808 105 buf[bufsize]=0;
12809
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
12811
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 zScript = string(buf);
12812
12813
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 delete[] buf;
12814 word numffcbindings;
12815 105 p_igetw(&numffcbindings, f, true);
12816
12817
2/2
✓ Branch 0 taken 1494 times.
✓ Branch 1 taken 105 times.
1599 for(int32_t i=0; i<numffcbindings; i++)
12818 {
12819 word id;
12820 1494 p_igetw(&id, f, true);
12821 1494 p_igetl(&bufsize, f, true);
12822 1494 buf = new char[bufsize+1];
12823 1494 pfread(buf, bufsize, f, true);
12824 1494 buf[bufsize]=0;
12825
12826 //fix for buggy older saved quests -DD
12827
2/4
✓ Branch 0 taken 1494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1494 times.
1494 if(keepdata && id < NUMSCRIPTFFC-1)
12828 1494 ffcmap[id].scriptname = buf;
12829
12830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1494 times.
1494 delete[] buf;
12831 1494 }
12832
12833 word numglobalbindings;
12834 105 p_igetw(&numglobalbindings, f, true);
12835
12836
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 105 times.
515 for(int32_t i=0; i<numglobalbindings; i++)
12837 {
12838 word id;
12839 410 p_igetw(&id, f, true);
12840 410 p_igetl(&bufsize, f, true);
12841 410 buf = new char[bufsize+1];
12842 410 pfread(buf, bufsize, f, true);
12843 410 buf[bufsize]=0;
12844
12845 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12846 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12847 // Ignore these. -DD
12848
4/6
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 251 times.
410 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12849 {
12850 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12851
1/2
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
251 if(strcmp(buf,"~Continue") == 0)
12852 {
12853 globalmap[id].scriptname = "";
12854
12855 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12856 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12857 }
12858 else
12859 {
12860 251 globalmap[id].scriptname = buf;
12861 }
12862 251 }
12863
12864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 delete[] buf;
12865 410 }
12866
12867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 3)
12868 {
12869 word numitembindings;
12870 105 p_igetw(&numitembindings, f, true);
12871
12872
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 105 times.
203 for(int32_t i=0; i<numitembindings; i++)
12873 {
12874 word id;
12875 98 p_igetw(&id, f, true);
12876 98 p_igetl(&bufsize, f, true);
12877 98 buf = new char[bufsize+1];
12878 98 pfread(buf, bufsize, f, true);
12879 98 buf[bufsize]=0;
12880
12881 //fix this too
12882
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if(keepdata && id <NUMSCRIPTITEM-1)
12883 98 itemmap[id].scriptname = buf;
12884
12885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12886 98 }
12887 105 }
12888 //(v9+)
12889
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 8)
12890 {
12891 //npc scripts
12892 word numnpcbindings;
12893 29 p_igetw(&numnpcbindings, f, true);
12894
12895
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 29 times.
41 for(int32_t i=0; i<numnpcbindings; i++)
12896 {
12897 word id;
12898 12 p_igetw(&id, f, true);
12899 12 p_igetl(&bufsize, f, true);
12900 12 buf = new char[bufsize+1];
12901 12 pfread(buf, bufsize, f, true);
12902 12 buf[bufsize]=0;
12903
12904 //fix this too
12905
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12906 12 npcmap[id].scriptname = buf;
12907
12908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12909 12 }
12910 //lweapon
12911 word numlwpnbindings;
12912 29 p_igetw(&numlwpnbindings, f, true);
12913
12914
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 29 times.
71 for(int32_t i=0; i<numlwpnbindings; i++)
12915 {
12916 word id;
12917 42 p_igetw(&id, f, true);
12918 42 p_igetl(&bufsize, f, true);
12919 42 buf = new char[bufsize+1];
12920 42 pfread(buf, bufsize, f, true);
12921 42 buf[bufsize]=0;
12922
12923 //fix this too
12924
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12925 42 lwpnmap[id].scriptname = buf;
12926
12927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12928 42 }
12929 //eweapon
12930 word numewpnbindings;
12931 29 p_igetw(&numewpnbindings, f, true);
12932
12933
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 29 times.
92 for(int32_t i=0; i<numewpnbindings; i++)
12934 {
12935 word id;
12936 63 p_igetw(&id, f, true);
12937 63 p_igetl(&bufsize, f, true);
12938 63 buf = new char[bufsize+1];
12939 63 pfread(buf, bufsize, f, true);
12940 63 buf[bufsize]=0;
12941
12942 //fix this too
12943
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12944 63 ewpnmap[id].scriptname = buf;
12945
12946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12947 63 }
12948 //hero
12949 word numherobindings;
12950 29 p_igetw(&numherobindings, f, true);
12951
12952
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 29 times.
34 for(int32_t i=0; i<numherobindings; i++)
12953 {
12954 word id;
12955 5 p_igetw(&id, f, true);
12956 5 p_igetl(&bufsize, f, true);
12957 5 buf = new char[bufsize+1];
12958 5 pfread(buf, bufsize, f, true);
12959 5 buf[bufsize]=0;
12960
12961 //fix this too
12962
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(keepdata && id <NUMSCRIPTPLAYER-1)
12963 5 playermap[id].scriptname = buf;
12964
12965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12966 5 }
12967 //dmaps
12968 word numdmapbindings;
12969 29 p_igetw(&numdmapbindings, f, true);
12970
12971
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 29 times.
54 for(int32_t i=0; i<numdmapbindings; i++)
12972 {
12973 word id;
12974 25 p_igetw(&id, f, true);
12975 25 p_igetl(&bufsize, f, true);
12976 25 buf = new char[bufsize+1];
12977 25 pfread(buf, bufsize, f, true);
12978 25 buf[bufsize]=0;
12979
12980 //fix this too
12981
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if(keepdata && id <NUMSCRIPTSDMAP-1)
12982 25 dmapmap[id].scriptname = buf;
12983
12984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 delete[] buf;
12985 25 }
12986 //screen
12987 word numscreenbindings;
12988 29 p_igetw(&numscreenbindings, f, true);
12989
12990
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 29 times.
47 for(int32_t i=0; i<numscreenbindings; i++)
12991 {
12992 word id;
12993 18 p_igetw(&id, f, true);
12994 18 p_igetl(&bufsize, f, true);
12995 18 buf = new char[bufsize+1];
12996 18 pfread(buf, bufsize, f, true);
12997 18 buf[bufsize]=0;
12998
12999 //fix this too
13000
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(keepdata && id <NUMSCRIPTSDMAP-1)
13001 18 screenmap[id].scriptname = buf;
13002
13003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
13004 18 }
13005 29 }
13006
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 11)
13007 {
13008 word numspritebindings;
13009 29 p_igetw(&numspritebindings, f, true);
13010
13011
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 29 times.
39 for(int32_t i=0; i<numspritebindings; i++)
13012 {
13013 word id;
13014 10 p_igetw(&id, f, true);
13015 10 p_igetl(&bufsize, f, true);
13016 10 buf = new char[bufsize+1];
13017 10 pfread(buf, bufsize, f, true);
13018 10 buf[bufsize]=0;
13019
13020 //fix this too
13021
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
13022 10 itemspritemap[id].scriptname = buf;
13023
13024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
13025 10 }
13026 29 }
13027
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 15)
13028 {
13029 word numcombobindings;
13030 29 p_igetw(&numcombobindings, f, true);
13031
13032
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 29 times.
52 for(int32_t i=0; i<numcombobindings; i++)
13033 {
13034 word id;
13035 23 p_igetw(&id, f, true);
13036 23 p_igetl(&bufsize, f, true);
13037 23 buf = new char[bufsize+1];
13038 23 pfread(buf, bufsize, f, true);
13039 23 buf[bufsize]=0;
13040
13041 //fix this too
13042
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
13043 23 comboscriptmap[id].scriptname = buf;
13044
13045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
13046 23 }
13047 29 }
13048
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 19)
13049 {
13050 word numgenericbindings;
13051 29 p_igetw(&numgenericbindings, f, true);
13052
13053
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 29 times.
42 for(int32_t i=0; i<numgenericbindings; i++)
13054 {
13055 word id;
13056 13 p_igetw(&id, f, true);
13057 13 p_igetl(&bufsize, f, true);
13058 13 buf = new char[bufsize+1];
13059 13 pfread(buf, bufsize, f, true);
13060 13 buf[bufsize]=0;
13061
13062 //fix this too
13063
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13064 13 genericmap[id].scriptname = buf;
13065
13066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
13067 13 }
13068 29 }
13069 105 }
13070
13071 105 return 0;
13072 105 }
13073
13074 114 void reset_scripts()
13075 {
13076 //OK, who spaced this? ;)
13077
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13078 {
13079
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58368 times.
58368 if(ffscripts[i]!=NULL) delete ffscripts[i];
13080 58368 }
13081
13082
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13083 {
13084
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(itemscripts[i]!=NULL) delete itemscripts[i];
13085 29184 }
13086
13087
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13088 {
13089
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(guyscripts[i]!=NULL) delete guyscripts[i];
13090 29184 }
13091
13092
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13093 {
13094
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13095 29184 }
13096
13097
13098
13099
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13100 {
13101
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(screenscripts[i]!=NULL) delete screenscripts[i];
13102 29184 }
13103
13104
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13105 {
13106
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 912 times.
912 if(globalscripts[i]!=NULL) delete globalscripts[i];
13107 912 }
13108
13109
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 114 times.
684 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13110 {
13111
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 570 times.
570 if(playerscripts[i]!=NULL) delete playerscripts[i];
13112 570 }
13113
13114
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13115 {
13116
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13117 29184 }
13118
13119
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13120 {
13121
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13122 29184 }
13123
13124
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13125 {
13126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13127 29184 }
13128
13129
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13130 {
13131
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13132 29184 }
13133
13134
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13135 {
13136
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58368 times.
58368 if(comboscripts[i]!=NULL) delete comboscripts[i];
13137 58368 }
13138
13139 114 next_script_data_debug_id = 0;
13140
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13141 {
13142
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 38912 times.
✗ Branch 3 not taken.
58368 if(genericscripts[i]!=NULL) delete genericscripts[i];
13143
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 genericscripts[i] = new script_data();
13144 58368 }
13145
13146
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13147 {
13148
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 ffscripts[i] = new script_data();
13149 58368 }
13150
13151
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13152 {
13153
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 itemscripts[i] = new script_data();
13154 29184 }
13155
13156
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13157 {
13158
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 guyscripts[i] = new script_data();
13159 29184 }
13160
13161
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13162 {
13163
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 wpnscripts[i] = new script_data();
13164 29184 }
13165
13166
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13167 {
13168
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 screenscripts[i] = new script_data();
13169 29184 }
13170
13171
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13172 {
13173
1/2
✓ Branch 0 taken 912 times.
✗ Branch 1 not taken.
912 globalscripts[i] = new script_data();
13174 912 }
13175
13176
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 114 times.
684 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13177 {
13178
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 playerscripts[i] = new script_data();
13179 570 }
13180
13181
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13182 {
13183
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 lwpnscripts[i] = new script_data();
13184 29184 }
13185
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13186 {
13187
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 ewpnscripts[i] = new script_data();
13188 29184 }
13189
13190
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13191 {
13192
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 dmapscripts[i] = new script_data();
13193 29184 }
13194
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13195 {
13196
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 itemspritescripts[i] = new script_data();
13197 29184 }
13198
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13199 {
13200
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 comboscripts[i] = new script_data();
13201 58368 }
13202 114 }
13203
13204 extern script_command command_list[];
13205 221581 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13206 {
13207 //Please also update loadquest() when modifying this method -DD
13208 221581 char b33[34] = {0};
13209 221581 b33[33] = 0;
13210 221581 ffscript temp_script;
13211 221581 int32_t num_commands=1000;
13212
13213
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(s_version>=2)
13214 {
13215
2/4
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221581 times.
✗ Branch 3 not taken.
221581 if(!p_igetl(&num_commands,f,true))
13216 {
13217 return qe_invalid;
13218 }
13219 221581 }
13220
13221
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(keepdata)
13222 {
13223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221581 times.
221581 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221581 times.
221581 delete (*script);
13225
2/4
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221581 times.
✗ Branch 3 not taken.
221581 (*script) = new script_data(num_commands);
13226 221581 }
13227
2/2
✓ Branch 0 taken 104313 times.
✓ Branch 1 taken 117268 times.
221581 if(s_version >= 16)
13228 {
13229
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 zasm_meta temp_meta;
13230
13231
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13232 {
13233 return qe_invalid;
13234 }
13235
13236
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.meta_v),f,true))
13237 {
13238 return qe_invalid;
13239 }
13240
13241
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13242 {
13243 return qe_invalid;
13244 }
13245
13246
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_getc(&(temp_meta.script_type),f,true))
13247 {
13248 return qe_invalid;
13249 }
13250
13251
2/2
✓ Branch 0 taken 834504 times.
✓ Branch 1 taken 104313 times.
938817 for(int32_t q = 0; q < 8; ++q)
13252 {
13253
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 776952 times.
834504 if(zmeta_version < 3)
13254 {
13255
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13256 {
13257
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13258 {
13259 return qe_invalid;
13260 }
13261 1899216 }
13262
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13263 57552 }
13264 else
13265 {
13266
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13267 {
13268 return qe_invalid;
13269 }
13270 }
13271 834504 }
13272
13273
2/2
✓ Branch 0 taken 104313 times.
✓ Branch 1 taken 834504 times.
938817 for(int32_t q = 0; q < 8; ++q)
13274 {
13275
2/4
✓ Branch 0 taken 834504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 834504 times.
✗ Branch 3 not taken.
834504 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13276 {
13277 return qe_invalid;
13278 }
13279 834504 }
13280
13281
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_getc(&(temp_meta.flags),f,true))
13282 {
13283 return qe_invalid;
13284 }
13285
13286
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13287 {
13288 return qe_invalid;
13289 }
13290
13291
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13292 {
13293 return qe_invalid;
13294 }
13295
13296
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13297 {
13298 return qe_invalid;
13299 }
13300
13301
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13302 {
13303 return qe_invalid;
13304 }
13305
13306
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 97119 times.
104313 if(zmeta_version == 2)
13307 {
13308
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13309 {
13310
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13311 {
13312 return qe_invalid;
13313 }
13314 237402 }
13315
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13316
13317
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13318 {
13319
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13320 {
13321 return qe_invalid;
13322 }
13323 237402 }
13324
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13325 7194 }
13326
1/2
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
97119 else if(zmeta_version > 2)
13327 {
13328
2/4
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97119 times.
✗ Branch 3 not taken.
97119 if(!p_getcstr(&temp_meta.script_name,f,true))
13329 return qe_invalid;
13330
2/4
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97119 times.
✗ Branch 3 not taken.
97119 if(!p_getcstr(&temp_meta.author,f,true))
13331 return qe_invalid;
13332 97119 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13333
2/2
✓ Branch 0 taken 971190 times.
✓ Branch 1 taken 97119 times.
1068309 for(auto q = 0; q < num_meta_attrib; ++q)
13334 {
13335
2/4
✓ Branch 0 taken 971190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 971190 times.
✗ Branch 3 not taken.
971190 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13336 return qe_invalid;
13337
2/4
✓ Branch 0 taken 971190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 971190 times.
✗ Branch 3 not taken.
971190 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13338 return qe_invalid;
13339 971190 }
13340
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13341 {
13342
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13343 return qe_invalid;
13344
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13345 return qe_invalid;
13346 776952 }
13347
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13348 {
13349
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13350 return qe_invalid;
13351
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13352 return qe_invalid;
13353 776952 }
13354
2/2
✓ Branch 0 taken 1553904 times.
✓ Branch 1 taken 97119 times.
1651023 for(auto q = 0; q < 16; ++q)
13355 {
13356
2/4
✓ Branch 0 taken 1553904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1553904 times.
✗ Branch 3 not taken.
1553904 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13357 return qe_invalid;
13358
2/4
✓ Branch 0 taken 1553904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1553904 times.
✗ Branch 3 not taken.
1553904 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13359 return qe_invalid;
13360 1553904 }
13361 97119 }
13362
2/2
✓ Branch 0 taken 97119 times.
✓ Branch 1 taken 7194 times.
104313 if(zmeta_version > 3)
13363 {
13364
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13365 {
13366
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.initd[q],f,true))
13367 return qe_invalid;
13368
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13369 return qe_invalid;
13370 776952 }
13371
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13372 {
13373
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getc(&temp_meta.initd_type[q],f,true))
13374 return qe_invalid;
13375 776952 }
13376 97119 }
13377 else
13378 {
13379
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13380 {
13381
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13382 57552 }
13383 }
13384
13385
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 if(keepdata)
13386
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 (*script)->meta = temp_meta;
13387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104313 times.
104313 }
13388
13389
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 temp_script.clear();
13390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21548942 times.
21548942 for(int32_t j=0; j<num_commands; j++)
13391 {
13392
2/4
✓ Branch 0 taken 21548942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21548942 times.
✗ Branch 3 not taken.
21548942 if(!p_igetw(&(temp_script.command),f,true))
13393 {
13394 return qe_invalid;
13395 }
13396
13397
2/2
✓ Branch 0 taken 21327361 times.
✓ Branch 1 taken 221581 times.
21548942 if(temp_script.command == 0xFFFF)
13398 {
13399
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(keepdata)
13400
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 (*script)->zasm[j].clear();
13401 221581 break;
13402 }
13403 else
13404 {
13405
2/4
✓ Branch 0 taken 21327361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21327361 times.
✗ Branch 3 not taken.
21327361 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13406 {
13407 return qe_invalid;
13408 }
13409
13410
2/4
✓ Branch 0 taken 21327361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21327361 times.
✗ Branch 3 not taken.
21327361 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13411 {
13412 return qe_invalid;
13413 }
13414
13415
2/2
✓ Branch 0 taken 655566 times.
✓ Branch 1 taken 20671795 times.
21327361 if(s_version >= 21)
13416 {
13417 655566 uint32_t sz = 0;
13418
2/4
✓ Branch 0 taken 655566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 655566 times.
✗ Branch 3 not taken.
655566 if(!p_igetl(&sz,f,keepdata))
13419 {
13420 return qe_invalid;
13421 }
13422
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 652758 times.
655566 if(sz) //string found
13423 {
13424
1/2
✓ Branch 0 taken 2808 times.
✗ Branch 1 not taken.
2808 temp_script.strptr = new std::string();
13425 char dummy;
13426
2/2
✓ Branch 0 taken 224176 times.
✓ Branch 1 taken 2808 times.
226984 for(size_t q = 0; q < sz; ++q)
13427 {
13428
2/4
✓ Branch 0 taken 224176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224176 times.
✗ Branch 3 not taken.
224176 if(!p_getc(&dummy,f,keepdata))
13429 {
13430 return qe_invalid;
13431 }
13432
1/2
✓ Branch 0 taken 224176 times.
✗ Branch 1 not taken.
224176 temp_script.strptr->push_back(dummy);
13433 224176 }
13434 2808 }
13435
2/4
✓ Branch 0 taken 655566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 655566 times.
✗ Branch 3 not taken.
655566 if(!p_igetl(&sz,f,keepdata))
13436 {
13437 return qe_invalid;
13438 }
13439
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 655465 times.
655566 if(sz) //vector found
13440 {
13441
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13442 int32_t dummy;
13443
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13444 {
13445
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f,keepdata))
13446 {
13447 return qe_invalid;
13448 }
13449
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13450 1487 }
13451 101 }
13452 655566 }
13453
13454
1/2
✓ Branch 0 taken 21327361 times.
✗ Branch 1 not taken.
21327361 if(keepdata)
13455 {
13456
1/2
✓ Branch 0 taken 21327361 times.
✗ Branch 1 not taken.
21327361 temp_script.give((*script)->zasm[j]);
13457 21327361 }
13458 }
13459
1/2
✓ Branch 0 taken 21327361 times.
✗ Branch 1 not taken.
21327361 temp_script.clear();
13460 21327361 }
13461
13462 221581 return 0;
13463 221581 }
13464
13465 extern SAMPLE customsfxdata[WAV_COUNT];
13466 extern uint8_t customsfxflag[WAV_COUNT>>3];
13467 extern int32_t sfxdat;
13468 extern DATAFILE *sfxdata;
13469 const char *old_sfx_string[Z35] =
13470 {
13471 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13472 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13473 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13474 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13475 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13476 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13477 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13478 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13479 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13480 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13481 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13482 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13483 };
13484 char *sfx_string[WAV_COUNT];
13485
13486 105 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13487 {
13488 //these are here to bypass compiler warnings about unused arguments
13489 105 Header=Header;
13490
13491 int32_t dummy;
13492 105 word s_version=0, s_cversion=0;
13493 //int32_t ret;
13494 SAMPLE temp_sample;
13495 105 temp_sample.loop_start=0;
13496 105 temp_sample.loop_end=0;
13497 105 temp_sample.param=0;
13498
13499 //section version info
13500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
13501 {
13502 return qe_invalid;
13503 }
13504
13505 105 FFCore.quest_format[vSFX] = s_version;
13506
13507 //al_trace("SFX version %d\n", s_version);
13508
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
13509 {
13510 return qe_invalid;
13511 }
13512
13513 //section size
13514
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
13515 {
13516 return qe_invalid;
13517 }
13518
13519 /* HIGHLY UNORTHODOX UPDATING THING, by L
13520 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13521 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13522 * changing from 1 to 2.
13523 */
13524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if(s_version < 2 && keepdata)
13525 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13526
13527 /* End highly unorthodox updating thing */
13528
13529 105 int32_t wavcount = WAV_COUNT;
13530
13531
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version < 6)
13532 wavcount = 128;
13533
13534 uint8_t tempflag[WAV_COUNT>>3];
13535
13536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version < 4)
13537 {
13538 memset(tempflag, 0xFF, WAV_COUNT>>3);
13539 }
13540 else
13541 {
13542
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version < 6)
13543 memset(tempflag, 0, WAV_COUNT>>3);
13544
13545
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 105 times.
3465 for(int32_t i=0; i<(wavcount>>3); i++)
13546 {
13547 3360 p_getc(&tempflag[i], f, true);
13548 3360 }
13549
13550 }
13551
13552
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version>4)
13553 {
13554
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 105 times.
26880 for(int32_t i=1; i<WAV_COUNT; i++)
13555 {
13556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26775 times.
26775 if(keepdata)
13557 {
13558 26775 sprintf(sfx_string[i],"s%03d",i);
13559
13560
2/2
✓ Branch 0 taken 20475 times.
✓ Branch 1 taken 6300 times.
26775 if((i<Z35))
13561 6300 strcpy(sfx_string[i], old_sfx_string[i-1]);
13562 26775 }
13563
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26775 times.
26775 if(i>=wavcount)
13565 continue;
13566
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 24262 times.
26775 if(get_bit(tempflag, i-1))
13567 {
13568 char tempname[36];
13569
13570
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!pfread(tempname, 36, f, keepdata))
13571 {
13572 return qe_invalid;
13573 }
13574
13575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2513 times.
2513 if(keepdata)
13576 {
13577 2513 strcpy(sfx_string[i], tempname);
13578 2513 sfx_string[i][35] = 0; //Force NULL Termination
13579 2513 }
13580 2513 }
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24262 times.
24262 else if(keepdata)
13582 {
13583 24262 sprintf(sfx_string[i],"s%03d",i);
13584
13585
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 4518 times.
24262 if(i<Z35)
13586 4518 strcpy(sfx_string[i], old_sfx_string[i-1]);
13587 24262 sfx_string[i][35] = 0; //Force NULL Termination
13588 24262 }
13589 26775 }
13590 105 }
13591 else
13592 {
13593 if(keepdata)
13594 {
13595 for(int32_t i=1; i<WAV_COUNT; i++)
13596 {
13597 sprintf(sfx_string[i],"s%03d",i);
13598
13599 if(i<Z35)
13600 strcpy(sfx_string[i], old_sfx_string[i-1]);
13601 }
13602 }
13603 }
13604
13605 //finally... section data
13606
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 105 times.
26880 for(int32_t i=1; i<wavcount; i++)
13607 {
13608
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 24262 times.
26775 if(get_bit(tempflag, i-1))
13609 {
13610
13611
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,true))
13612 {
13613 return qe_invalid;
13614 }
13615
13616 2513 (temp_sample.bits) = dummy;
13617
13618
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,true))
13619 {
13620 return qe_invalid;
13621 }
13622
13623 2513 (temp_sample.stereo) = dummy;
13624
13625
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,keepdata))
13626 {
13627 return qe_invalid;
13628 }
13629
13630 2513 (temp_sample.freq) = dummy;
13631
13632
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,keepdata))
13633 {
13634 return qe_invalid;
13635 }
13636
13637 2513 (temp_sample.priority) = dummy;
13638
13639
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.len),f,true))
13640 {
13641 return qe_invalid;
13642 }
13643
13644
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13645 {
13646 return qe_invalid;
13647 }
13648
13649
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13650 {
13651 return qe_invalid;
13652 }
13653
13654
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.param),f,keepdata))
13655 {
13656 return qe_invalid;
13657 }
13658
13659 // al_trace("F%i: L%i\n",i,temp_sample.len);
13660 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13661 2513 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13662 2513 temp_sample.data = calloc(len,1);
13663
13664
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(s_version < 3)
13665 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13666
13667 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2513 times.
2513 if(s_version < 2)
13669 {
13670 if(!pfread(temp_sample.data, len,f,keepdata))
13671 {
13672 return qe_invalid;
13673 }
13674 }
13675 else
13676 {
13677 //re-endianfy the data
13678 2513 int32_t wordstoread = len / sizeof(word);
13679
13680
2/2
✓ Branch 0 taken 76164518 times.
✓ Branch 1 taken 2513 times.
76167031 for(int32_t j=0; j<wordstoread; j++)
13681 {
13682 word temp;
13683
13684
1/2
✓ Branch 0 taken 76164518 times.
✗ Branch 1 not taken.
76164518 if(!p_igetw(&temp, f, keepdata))
13685 {
13686 return qe_invalid;
13687 }
13688
13689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76164518 times.
76164518 if(keepdata)
13690 76164518 ((word *)temp_sample.data)[j] = temp;
13691 76164518 }
13692 }
13693 2513 }
13694
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 19744 times.
24262 else if(i < Z35)
13695 {
13696 4518 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13697 4518 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13698 4518 set_bit(tempflag, i-1, 1);
13699 4518 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13700 4518 temp_sample.data = calloc(len,1);
13701 4518 memcpy(temp_sample.data, datsamp->data, len);
13702 4518 }
13703 19744 else continue;
13704
13705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7031 times.
7031 if(keepdata)
13706 {
13707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7031 times.
7031 if(customsfxdata[i].data!=NULL)
13708 {
13709 // delete [] customsfxdata[i].data;
13710 7031 free(customsfxdata[i].data);
13711 7031 }
13712
13713 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13714 7031 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13715 7031 customsfxdata[i].data = calloc(len2,1);
13716 7031 customsfxdata[i].bits = temp_sample.bits;
13717 7031 customsfxdata[i].stereo = temp_sample.stereo;
13718 7031 customsfxdata[i].freq = temp_sample.freq;
13719 7031 customsfxdata[i].priority = temp_sample.priority;
13720 7031 customsfxdata[i].len = temp_sample.len;
13721 7031 customsfxdata[i].loop_start = temp_sample.loop_start;
13722 7031 customsfxdata[i].loop_end = temp_sample.loop_end;
13723 7031 customsfxdata[i].param = temp_sample.param;
13724 7031 int32_t cpylen = len2;
13725
13726
1/2
✓ Branch 0 taken 7031 times.
✗ Branch 1 not taken.
7031 if(s_version<3)
13727 {
13728 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13729 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13730 }
13731
13732 7031 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13733 7031 }
13734
13735 7031 free(temp_sample.data);
13736 7031 }
13737
13738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
13739 105 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13740
13741 105 sfxdat=0;
13742 105 return 0;
13743 105 }
13744
13745 114 void setupsfx()
13746 {
13747
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<WAV_COUNT; i++)
13748 {
13749 29070 sprintf(sfx_string[i],"s%03d",i);
13750
13751
2/2
✓ Branch 0 taken 22230 times.
✓ Branch 1 taken 6840 times.
29070 if(i<Z35)
13752 {
13753 6840 strcpy(sfx_string[i], old_sfx_string[i-1]);
13754 6840 }
13755
13756 29070 memset(customsfxflag, 0, WAV_COUNT>>3);
13757
13758 29070 int32_t j=i;
13759
13760
2/2
✓ Branch 0 taken 6954 times.
✓ Branch 1 taken 22116 times.
29070 if(i>Z35)
13761 {
13762 22116 i=Z35;
13763 22116 }
13764
13765 29070 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13766
13767
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 19380 times.
29070 if(customsfxdata[j].data!=NULL)
13768 {
13769 // delete [] customsfxdata[j].data;
13770 19380 free(customsfxdata[j].data);
13771 19380 }
13772
13773 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13774 29070 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13775 29070 customsfxdata[j].bits = temp_sample->bits;
13776 29070 customsfxdata[j].stereo = temp_sample->stereo;
13777 29070 customsfxdata[j].freq = temp_sample->freq;
13778 29070 customsfxdata[j].priority = temp_sample->priority;
13779 29070 customsfxdata[j].len = temp_sample->len;
13780 29070 customsfxdata[j].loop_start = temp_sample->loop_start;
13781 29070 customsfxdata[j].loop_end = temp_sample->loop_end;
13782 29070 customsfxdata[j].param = temp_sample->param;
13783 29070 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13784 29070 i=j;
13785 29070 }
13786 114 }
13787
13788 extern char *guy_string[eMAXGUYS];
13789 extern const char *old_guy_string[OLDMAXGUYS];
13790
13791 114 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13792 {
13793 dword dummy;
13794 word guy_cversion;
13795 114 word guyversion=0;
13796
13797
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version >= 0x193)
13798 {
13799 //section version info
13800
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&guyversion,f,true))
13801 {
13802 return qe_invalid;
13803 }
13804
13805 110 FFCore.quest_format[vGuys] = guyversion;
13806
13807 //al_trace("Guys version %d\n", guyversion);
13808
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&guy_cversion,f,true))
13809 {
13810 return qe_invalid;
13811 }
13812 110 al_trace("Guy CVersion is: %d\n", guy_cversion);
13813 //section size
13814
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
13815 {
13816 return qe_invalid;
13817 }
13818 110 }
13819
13820
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(guyversion > 3)
13821 {
13822
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXGUYS; i++)
13823 {
13824 char tempname[64];
13825
13826 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13827 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13828
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53760 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13829 {
13830 memset(tempname, 0, sizeof(char)*64);
13831 sprintf(tempname, "e%03d", i);
13832 strcpy(guy_string[i], tempname);
13833
13834 continue;
13835 }
13836
13837
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!pfread(tempname, 64, f, keepdata))
13838 {
13839 return qe_invalid;
13840 }
13841
13842 // Don't retain names of uneditable enemy entries!
13843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(keepdata)
13844 {
13845 // for version upgrade to 2.5
13846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53760 if(guyversion < 23 && i >= 177)
13847 {
13848 // some of the older builds have names such as 'zz123',
13849 // (this order gets messed up with some eXXX and some zzXXX)
13850 // so let's update to the newer naming convection. -Gleeok
13851 char tmpbuf[64];
13852 memset(tmpbuf, 0, sizeof(char)*64);
13853 sprintf(tmpbuf, "zz%03d", i);
13854
13855 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13856 {
13857 memset(tempname, 0, sizeof(char)*64);
13858 sprintf(tempname, "e%03d", i);
13859 }
13860 }
13861
13862
6/6
✓ Branch 0 taken 18585 times.
✓ Branch 1 taken 35175 times.
✓ Branch 2 taken 17640 times.
✓ Branch 3 taken 945 times.
✓ Branch 4 taken 14683 times.
✓ Branch 5 taken 2957 times.
53760 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13863 {
13864 50803 strcpy(guy_string[i], tempname);
13865 50803 }
13866 else
13867 {
13868 2957 strcpy(guy_string[i],old_guy_string[i]);
13869 }
13870 53760 }
13871 53760 }
13872 105 }
13873 else
13874 {
13875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13876 {
13877
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13878 {
13879 4608 sprintf(guy_string[i],"zz%03d",i);
13880 4608 }
13881
13882
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13883 {
13884 1593 strcpy(guy_string[i],old_guy_string[i]);
13885 1593 }
13886 9 }
13887 }
13888
13889
13890 //finally... section data
13891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
13892 {
13893 114 init_guys(guyversion); //using default data for now...
13894
13895 // Goriya guy fix
13896
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13897 {
13898
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13899 {
13900 5 guysbuf[gGORIYA].tile=130;
13901 5 guysbuf[gGORIYA].e_tile=130;
13902 5 }
13903 9 }
13904 114 }
13905
13906
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version < 0x193)
13907 {
13908
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13909 {
13910 guysbuf[eDODONGO].cset=14;
13911 guysbuf[eDODONGO].bosspal=spDIG;
13912 }
13913 4 }
13914 // Not sure when this first changed, but it's necessary for 2.10, at least
13915 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13916 //2.10 Fixes
13917
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13918 {
13919 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13920 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13921 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13922 9 guysbuf[eCENT1].misc3 = 1;
13923 9 guysbuf[eCENT2].misc3 = 1;
13924 9 }
13925
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13926 {
13927 114 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13928 114 }
13929
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(Header->zelda_version <= 0x210)
13930 {
13931 9 guysbuf[eGLEEOK1F].misc6 = 16;
13932 9 guysbuf[eGLEEOK2F].misc6 = 16;
13933 9 guysbuf[eGLEEOK3F].misc6 = 16;
13934 9 guysbuf[eGLEEOK4F].misc6 = 16;
13935
13936 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13937 9 guysbuf[eBATROBE].misc4 = 1;
13938 //guysbuf[eSUMMONER].misc4 = 1;
13939 9 guysbuf[eWWIZ].misc4 = 1;
13940 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13941 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13942 9 }
13943
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version == 0x190)
13944 {
13945 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13946 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13947 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13948 4 }
13949
13950 // The versions here may not be correct
13951 // zelda_version>=0x211 handled at guyversion<24
13952
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version <= 0x190)
13953 {
13954 4 guysbuf[eCENT1].misc3 = 0;
13955 4 guysbuf[eCENT2].misc3 = 0;
13956 4 guysbuf[eMOLDORM].misc2 = 0;
13957 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13958 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13959 4 }
13960
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 else if(Header->zelda_version <= 0x210)
13961 {
13962 5 guysbuf[eCENT1].misc3 = 1;
13963 5 guysbuf[eCENT2].misc3 = 1;
13964 5 guysbuf[eMOLDORM].misc2 = 0;
13965 5 }
13966
13967
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13968 {
13969 9 guysbuf[eKEESE1].misc16 = 120;
13970 9 guysbuf[eKEESE2].misc16 = 120;
13971 9 guysbuf[eKEESE3].misc16 = 120;
13972 9 guysbuf[eKEESETRIB].misc16 = 120;
13973 9 guysbuf[eKEESE1].misc17 = 16;
13974 9 guysbuf[eKEESE2].misc17 = 16;
13975 9 guysbuf[eKEESE3].misc17 = 16;
13976 9 guysbuf[eKEESETRIB].misc17 = 16;
13977
13978 9 guysbuf[ePEAHAT].misc16 = 80;
13979 9 guysbuf[ePEAHAT].misc17 = 16;
13980
13981 9 guysbuf[eGHINI2].misc16 = 120;
13982 9 guysbuf[eGHINI2].misc17 = 10;
13983
13984 9 }
13985
13986
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(guyversion<=2)
13987 {
13988 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13989 }
13990
13991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(guyversion > 3)
13992 {
13993 guydata tempguy;
13994
13995
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXGUYS; i++)
13996 {
13997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53760 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13998 {
13999 if(i >= OLDBETAMAXGUYS)
14000 {
14001 memset(&guysbuf[i], 0, sizeof(guydata));
14002 continue;
14003 }
14004 }
14005
14006 53760 memset(&tempguy, 0, sizeof(guydata));
14007
14008
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.flags),f,keepdata))
14009 {
14010 return qe_invalid;
14011 }
14012
14013
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.flags2),f,keepdata))
14014 {
14015 return qe_invalid;
14016 }
14017
14018
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14019 {
14020
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.tile),f,keepdata))
14021 {
14022 return qe_invalid;
14023 }
14024 14848 }
14025 else
14026 {
14027
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.tile),f,keepdata))
14028 {
14029 return qe_invalid;
14030 }
14031 }
14032
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.width),f,keepdata))
14033 {
14034 return qe_invalid;
14035 }
14036
14037
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.height),f,keepdata))
14038 {
14039 return qe_invalid;
14040 }
14041
14042
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14043 {
14044
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
14045 {
14046 return qe_invalid;
14047 }
14048 14848 }
14049 else
14050 {
14051
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14052 {
14053 return qe_invalid;
14054 }
14055 }
14056
14057
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.s_width),f,keepdata))
14058 {
14059 return qe_invalid;
14060 }
14061
14062
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.s_height),f,keepdata))
14063 {
14064 return qe_invalid;
14065 }
14066
14067
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14068 {
14069
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14070 {
14071 return qe_invalid;
14072 }
14073 14848 }
14074 else
14075 {
14076
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14077 {
14078 return qe_invalid;
14079 }
14080 }
14081
14082
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.e_width),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.e_height),f,keepdata))
14088 {
14089 return qe_invalid;
14090 }
14091
14092
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.hp),f,keepdata))
14093 {
14094 return qe_invalid;
14095 }
14096
14097
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.family),f,keepdata))
14098 {
14099 return qe_invalid;
14100 }
14101
14102
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
53760 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14103 {
14104 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14105 {
14106 tempguy.s_tile=tempguy.e_tile+120;
14107 tempguy.s_width=tempguy.e_width;
14108 tempguy.s_height=tempguy.e_height;
14109 }
14110 else tempguy.s_tile=860;
14111 }
14112
14113
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.cset),f,keepdata))
14114 {
14115 return qe_invalid;
14116 }
14117
14118
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.anim),f,keepdata))
14119 {
14120 return qe_invalid;
14121 }
14122
14123
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14124 {
14125 return qe_invalid;
14126 }
14127
14128
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.frate),f,keepdata))
14129 {
14130 return qe_invalid;
14131 }
14132
14133
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14134 {
14135 return qe_invalid;
14136 }
14137
14138
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 13) // April 2009
14139 {
14140 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14141 {
14142 tempguy.frate *= 2;
14143 tempguy.e_frate *= 2;
14144 }
14145 }
14146
14147
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 14) // May 1 2009
14148 {
14149 if(tempguy.anim==a2FRMSLOW)
14150 {
14151 tempguy.anim=a2FRM;
14152 tempguy.frate *= 2;
14153 }
14154
14155 if(tempguy.e_anim==a2FRMSLOW)
14156 {
14157 tempguy.e_anim=a2FRM;
14158 tempguy.e_frate *= 2;
14159 }
14160
14161 if(tempguy.anim==aFLIPSLOW)
14162 {
14163 tempguy.anim=aFLIP;
14164 tempguy.frate *= 2;
14165 }
14166
14167 if(tempguy.e_anim==aFLIPSLOW)
14168 {
14169 tempguy.e_anim=aFLIP;
14170 tempguy.e_frate *= 2;
14171 }
14172
14173 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14174
14175 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14176
14177 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14178 {
14179 tempguy.anim=a4FRM4DIR;
14180 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14181 }
14182
14183 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14184 {
14185 tempguy.e_anim=a4FRM4DIR;
14186 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14187 }
14188 }
14189
14190
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.dp),f,keepdata))
14191 {
14192 return qe_invalid;
14193 }
14194
14195 //correction for guy fire
14196
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 6)
14197 {
14198 if(i == gFIRE)
14199 tempguy.dp = 2;
14200 }
14201
14202
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14203 {
14204 return qe_invalid;
14205 }
14206
14207
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14208 {
14209 return qe_invalid;
14210 }
14211
14212 //correction for bosses using triple, "rising" fireballs
14213
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 5)
14214 {
14215 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14216 i == eGOHMA3 || i == eGOHMA4)
14217 {
14218 if(tempguy.weapon == ewFireball)
14219 tempguy.weapon = ewFireball2;
14220 }
14221 }
14222
14223
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.rate),f,keepdata))
14224 {
14225 return qe_invalid;
14226 }
14227
14228
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14229 {
14230 return qe_invalid;
14231 }
14232
14233
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.step),f,keepdata))
14234 {
14235 return qe_invalid;
14236 }
14237
14238 // HIGHLY UNORTHODOX UPDATING THING, part 2
14239
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 52224 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
53760 if(fixpolsvoice && tempguy.family==eePOLSV)
14240 {
14241 tempguy.step /= 2;
14242 }
14243
14244
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.homing),f,keepdata))
14245 {
14246 return qe_invalid;
14247 }
14248
14249
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14250 {
14251 return qe_invalid;
14252 }
14253
14254
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14255 {
14256 return qe_invalid;
14257 }
14258
14259
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14260 {
14261
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14262 {
14263 return qe_invalid;
14264 }
14265
14266
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14267 {
14268 return qe_invalid;
14269 }
14270
14271
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14272 {
14273 return qe_invalid;
14274 }
14275
14276
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14277 {
14278 return qe_invalid;
14279 }
14280
14281
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14282 {
14283 return qe_invalid;
14284 }
14285
14286
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14287 {
14288 return qe_invalid;
14289 }
14290
14291
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14292 {
14293 return qe_invalid;
14294 }
14295
14296
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14297 {
14298 return qe_invalid;
14299 }
14300
14301
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14302 {
14303 return qe_invalid;
14304 }
14305
14306
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14307 {
14308 return qe_invalid;
14309 }
14310 53760 }
14311 else
14312 {
14313 int16_t tempMisc;
14314
14315 if(!p_igetw(&tempMisc,f,keepdata))
14316 {
14317 return qe_invalid;
14318 }
14319
14320 tempguy.misc1=tempMisc;
14321
14322 if(!p_igetw(&tempMisc,f,keepdata))
14323 {
14324 return qe_invalid;
14325 }
14326
14327 tempguy.misc2=tempMisc;
14328
14329 if(!p_igetw(&tempMisc,f,keepdata))
14330 {
14331 return qe_invalid;
14332 }
14333
14334 tempguy.misc3=tempMisc;
14335
14336 if(!p_igetw(&tempMisc,f,keepdata))
14337 {
14338 return qe_invalid;
14339 }
14340
14341 tempguy.misc4=tempMisc;
14342
14343 if(!p_igetw(&tempMisc,f,keepdata))
14344 {
14345 return qe_invalid;
14346 }
14347
14348 tempguy.misc5=tempMisc;
14349
14350 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14351 {
14352 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14353 tempguy.misc5 = 74;
14354 }
14355
14356 if(!p_igetw(&tempMisc,f,keepdata))
14357 {
14358 return qe_invalid;
14359 }
14360
14361 tempguy.misc6=tempMisc;
14362
14363 if(!p_igetw(&tempMisc,f,keepdata))
14364 {
14365 return qe_invalid;
14366 }
14367
14368 tempguy.misc7=tempMisc;
14369
14370 if(!p_igetw(&tempMisc,f,keepdata))
14371 {
14372 return qe_invalid;
14373 }
14374
14375 tempguy.misc8=tempMisc;
14376
14377 if(!p_igetw(&tempMisc,f,keepdata))
14378 {
14379 return qe_invalid;
14380 }
14381
14382 tempguy.misc9=tempMisc;
14383
14384 if(!p_igetw(&tempMisc,f,keepdata))
14385 {
14386 return qe_invalid;
14387 }
14388
14389 tempguy.misc10=tempMisc;
14390 }
14391
14392
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14393 {
14394 return qe_invalid;
14395 }
14396
14397
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14398 {
14399 return qe_invalid;
14400 }
14401
14402
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.extend),f,keepdata))
14403 {
14404 return qe_invalid;
14405 }
14406
14407 //! Enemy Defences
14408
14409 //If a 2.50 quest, use only the 2.5 defences.
14410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14411 {
14412
2/2
✓ Branch 0 taken 1021440 times.
✓ Branch 1 taken 53760 times.
1075200 for(int32_t j=0; j<edefLAST; j++)
14413 {
14414
1/2
✓ Branch 0 taken 1021440 times.
✗ Branch 1 not taken.
1021440 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14415 {
14416 return qe_invalid;
14417 }
14418 1021440 }
14419 //then copy the generic script defence to all the new script defences
14420
14421 53760 }
14422
14423
14424
14425
14426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(guyversion >= 18)
14427 {
14428
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14429 {
14430 return qe_invalid;
14431 }
14432
14433
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14434 {
14435 return qe_invalid;
14436 }
14437 53760 }
14438
14439
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion >= 22)
14440 {
14441
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14442 {
14443 return qe_invalid;
14444 }
14445
14446
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14447 {
14448 return qe_invalid;
14449 }
14450 53760 }
14451 else if(guyversion >= 19)
14452 {
14453 int16_t tempMisc;
14454
14455 if(!p_igetw(&tempMisc,f,keepdata))
14456 {
14457 return qe_invalid;
14458 }
14459
14460 tempguy.misc11=tempMisc;
14461
14462 if(!p_igetw(&tempMisc,f,keepdata))
14463 {
14464 return qe_invalid;
14465 }
14466
14467 tempguy.misc12=tempMisc;
14468 }
14469
14470 //If a 2.54 or later quest, use all of the defences.
14471
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 24) // Add new guyversion conditional statement
14472 {
14473
2/2
✓ Branch 0 taken 326656 times.
✓ Branch 1 taken 14848 times.
341504 for(int32_t j=edefLAST; j<edefLAST255; j++)
14474 {
14475
1/2
✓ Branch 0 taken 326656 times.
✗ Branch 1 not taken.
326656 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14476 {
14477 return qe_invalid;
14478 }
14479 326656 }
14480 14848 }
14481
14482
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14483 {
14484
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14485 {
14486 389120 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14487 389120 }
14488 38912 }
14489
14490 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14491
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 25)
14492 {
14493
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14494 {
14495 return qe_invalid;
14496 }
14497
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14498 {
14499 return qe_invalid;
14500 }
14501
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14502 {
14503 return qe_invalid;
14504 }
14505
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14506 {
14507 return qe_invalid;
14508 }
14509
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14510 {
14511 return qe_invalid;
14512 }
14513 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14514
14515 */
14516 14848 }
14517 //More Enemy Editor vars for 2.60
14518
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 26)
14519 {
14520
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14521 {
14522 return qe_invalid;
14523 }
14524
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14525 {
14526 return qe_invalid;
14527 }
14528
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14533 {
14534 return qe_invalid;
14535 }
14536
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14537 {
14538 return qe_invalid;
14539 }
14540 14848 }
14541
14542
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14543 {
14544 38912 tempguy.wpnsprite = 0;
14545 38912 }
14546
14547
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 27)
14548 {
14549
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14550 {
14551 return qe_invalid;
14552 }
14553 14848 }
14554
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14555 {
14556 38912 tempguy.SIZEflags = 0;
14557 38912 }
14558
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 28)
14559 {
14560
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14561 {
14562 return qe_invalid;
14563 }
14564
14565 14848 }
14566
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14567 {
14568 38912 tempguy.frozentile = 0;
14569 38912 tempguy.frozencset = 0;
14570 38912 tempguy.frozenclock = 0;
14571
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14572 38912 }
14573
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 30)
14574 {
14575
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14576 {
14577 return qe_invalid;
14578 }
14579
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14580 {
14581 return qe_invalid;
14582 }
14583
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14584 {
14585 return qe_invalid;
14586 }
14587
2/2
✓ Branch 0 taken 148480 times.
✓ Branch 1 taken 14848 times.
163328 for ( int32_t q = 0; q < 10; q++ ) {
14588
1/2
✓ Branch 0 taken 148480 times.
✗ Branch 1 not taken.
148480 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14589 {
14590 return qe_invalid;
14591 }
14592 148480 }
14593
14594 14848 }
14595
14596
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 34)
14597 {
14598
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14599 {
14600 return qe_invalid;
14601 }
14602
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14603 {
14604 return qe_invalid;
14605 }
14606
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14607 {
14608 return qe_invalid;
14609 }
14610
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14611 {
14612 return qe_invalid;
14613 }
14614
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14615 {
14616 return qe_invalid;
14617 }
14618
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14619 {
14620 return qe_invalid;
14621 }
14622
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14623 {
14624 return qe_invalid;
14625 }
14626
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14627 {
14628 return qe_invalid;
14629 }
14630
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14631 {
14632 return qe_invalid;
14633 }
14634
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14635 {
14636 return qe_invalid;
14637 }
14638
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14639 {
14640 return qe_invalid;
14641 }
14642
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14643 {
14644 return qe_invalid;
14645 }
14646
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14647 {
14648 return qe_invalid;
14649 }
14650
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14651 {
14652 return qe_invalid;
14653 }
14654
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14655 {
14656 return qe_invalid;
14657 }
14658
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14659 {
14660 return qe_invalid;
14661 }
14662
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14663 {
14664 return qe_invalid;
14665 }
14666
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14667 {
14668 return qe_invalid;
14669 }
14670
14671
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 14848 times.
489984 for ( int32_t q = 0; q < 32; q++ ) {
14672
1/2
✓ Branch 0 taken 475136 times.
✗ Branch 1 not taken.
475136 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14673 {
14674 return qe_invalid;
14675 }
14676 475136 }
14677
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 14848 times.
489984 for ( int32_t q = 0; q < 32; q++ ) {
14678
1/2
✓ Branch 0 taken 475136 times.
✗ Branch 1 not taken.
475136 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14679 {
14680 return qe_invalid;
14681 }
14682 475136 }
14683
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.script),f,keepdata))
14684 {
14685 return qe_invalid;
14686 }
14687 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14688
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14689 {
14690
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14691 {
14692 return qe_invalid;
14693 }
14694 118784 }
14695
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 14848 times.
44544 for ( int32_t q = 0; q < 2; q++ )
14696 {
14697
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14698 {
14699 return qe_invalid;
14700 }
14701 29696 }
14702
14703 14848 }
14704
14705
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 37)
14706 {
14707
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14708 {
14709 return qe_invalid;
14710 }
14711 14848 }
14712
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14713
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 38)
14714 {
14715
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14716 {
14717 return qe_invalid;
14718 }
14719
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14720 {
14721 return qe_invalid;
14722 }
14723
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14724 {
14725 return qe_invalid;
14726 }
14727
14728 14848 }
14729
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 38 )
14730 {
14731 38912 tempguy.misc13 = 0;
14732 38912 tempguy.misc14 = 0;
14733 38912 tempguy.misc15 = 0;
14734 38912 }
14735
14736
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 39 )
14737 {
14738
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14739 {
14740
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
14741 {
14742
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14743 {
14744 return qe_invalid;
14745 }
14746 7720960 }
14747
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
14748 {
14749
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14750 {
14751 return qe_invalid;
14752 }
14753 7720960 }
14754 118784 }
14755
14756
14757 14848 }
14758
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 39 ) //apply old InitD strings to both
14759 {
14760
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ )
14761 {
14762 311296 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14763 311296 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14764 311296 }
14765 38912 }
14766
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 40 )
14767 {
14768
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14769 {
14770 return qe_invalid;
14771 }
14772 14848 }
14773
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 40 )
14774 {
14775 38912 tempguy.weaponscript = 0;
14776 38912 }
14777 //eweapon script InitD
14778
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 41 )
14779 {
14780
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14781 {
14782
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14783 {
14784 return qe_invalid;
14785 }
14786 118784 }
14787
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if ( guy_cversion < 4 )
14788 {
14789 if ( tempguy.family == eeKEESE )
14790 {
14791
14792 if ( !tempguy.misc1 )
14793 {
14794 tempguy.misc16 = 120;
14795 tempguy.misc17 = 16;
14796
14797 }
14798 }
14799 if ( tempguy.family == eePEAHAT )
14800 {
14801 tempguy.misc16 = 80;
14802 tempguy.misc17 = 16;
14803 }
14804
14805 if ( tempguy.family == eeGHINI )
14806 {
14807 tempguy.misc16 = 120;
14808 tempguy.misc17 = 10;
14809 }
14810
14811 }
14812 14848 }
14813
14814
14815
14816 //default weapon sprites (quest version < 2.54)
14817 //port over old defaults -Z
14818
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 32)
14819 {
14820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.wpnsprite <= 0 )
14821 {
14822
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14823 {
14824 case wNone:
14825 32390 tempguy.wpnsprite = 0; break;
14826
14827 case wSword:
14828 case wBeam:
14829 case wBrang:
14830 case wBomb:
14831 case wSBomb:
14832 case wLitBomb:
14833 case wLitSBomb:
14834 case wArrow:
14835 case wFire:
14836 case wWhistle:
14837 case wBait:
14838 case wWand:
14839 case wMagic:
14840 case wCatching:
14841 case wWind:
14842 case wRefMagic:
14843 case wRefFireball:
14844 case wRefRock:
14845 case wHammer:
14846 case wHookshot:
14847 case wHSHandle:
14848 case wHSChain:
14849 case wSSparkle:
14850 case wFSparkle:
14851 case wSmack:
14852 case wPhantom:
14853 case wCByrna:
14854 case wRefBeam:
14855 case wStomp:
14856 case lwMax:
14857 case wScript1:
14858 case wScript2:
14859 case wScript3:
14860 case wScript4:
14861 case wScript5:
14862 case wScript6:
14863 case wScript7:
14864 case wScript8:
14865 case wScript9:
14866 case wScript10:
14867 case wIce:
14868 //Cannot use any of these weapons yet.
14869 tempguy.wpnsprite = -1;
14870 break;
14871
14872 case wEnemyWeapons:
14873 1292 case ewFireball: tempguy.wpnsprite = 17; break;
14874
14875 299 case ewArrow: tempguy.wpnsprite = 19; break;
14876 311 case ewBrang: tempguy.wpnsprite = 4; break;
14877 924 case ewSword: tempguy.wpnsprite = 20; break;
14878 488 case ewRock: tempguy.wpnsprite = 18; break;
14879 904 case ewMagic: tempguy.wpnsprite = 21; break;
14880 79 case ewBomb: tempguy.wpnsprite = 78; break;
14881 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14882 135 case ewLitBomb: tempguy.wpnsprite = 76; break;
14883 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14884 359 case ewFireTrail: tempguy.wpnsprite = 80; break;
14885 751 case ewFlame: tempguy.wpnsprite = 35; break;
14886 105 case ewWind: tempguy.wpnsprite = 36; break;
14887 79 case ewFlame2: tempguy.wpnsprite = 81; break;
14888 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14889 case ewIce: tempguy.wpnsprite = 83; break;
14890 759 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14891
14892
14893 default: break; //No assign.
14894 }
14895 38912 }
14896 38912 }
14897
14898 //default weapon fire sound (quest version < 2.54)
14899 //port over old defaults and zero new data. -Z
14900
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 34)
14901 {
14902
2/2
✓ Branch 0 taken 1245184 times.
✓ Branch 1 taken 38912 times.
1284096 for ( int32_t q = 0; q < 32; q++ )
14903 {
14904 1245184 tempguy.movement[q] = 0;
14905 1245184 tempguy.new_weapon[q] = 0;
14906
14907 1245184 }
14908
14909 //NPC Script attributes.
14910 38912 tempguy.script = 0; //No scripted enemies existed. -Z
14911
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14912
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 38912 times.
116736 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14913
14914 38912 tempguy.misc16 = 0;
14915 38912 tempguy.misc17 = 0;
14916 38912 tempguy.misc18 = 0;
14917 38912 tempguy.misc19 = 0;
14918 38912 tempguy.misc20 = 0;
14919 38912 tempguy.misc21 = 0;
14920 38912 tempguy.misc22 = 0;
14921 38912 tempguy.misc23 = 0;
14922 38912 tempguy.misc24 = 0;
14923 38912 tempguy.misc25 = 0;
14924 38912 tempguy.misc26 = 0;
14925 38912 tempguy.misc27 = 0;
14926 38912 tempguy.misc28 = 0;
14927 38912 tempguy.misc29 = 0;
14928 38912 tempguy.misc30 = 0;
14929 38912 tempguy.misc31 = 0;
14930 38912 tempguy.misc32 = 0;
14931
14932 //old default sounds
14933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.firesfx <= 0 )
14934 {
14935
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14936 {
14937 case wNone:
14938 32390 tempguy.firesfx = 0; break;
14939
14940 case wSword:
14941 case wBeam:
14942 case wBrang:
14943 case wBomb:
14944 case wSBomb:
14945 case wLitBomb:
14946 case wLitSBomb:
14947 case wArrow:
14948 case wFire:
14949 case wWhistle:
14950 case wBait:
14951 case wWand:
14952 case wMagic:
14953 case wCatching:
14954 case wWind:
14955 case wRefMagic:
14956 case wRefFireball:
14957 case wRefRock:
14958 case wHammer:
14959 case wHookshot:
14960 case wHSHandle:
14961 case wHSChain:
14962 case wSSparkle:
14963 case wFSparkle:
14964 case wSmack:
14965 case wPhantom:
14966 case wCByrna:
14967 case wRefBeam:
14968 case wStomp:
14969 case lwMax:
14970 case wScript1:
14971 case wScript2:
14972 case wScript3:
14973 case wScript4:
14974 case wScript5:
14975 case wScript6:
14976 case wScript7:
14977 case wScript8:
14978 case wScript9:
14979 case wScript10:
14980 case wIce:
14981 //Cannot use any of these weapons yet.
14982 tempguy.firesfx = -1;
14983 break;
14984
14985 case wEnemyWeapons:
14986 1292 case ewFireball: tempguy.firesfx = 40; break;
14987
14988 299 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14989 311 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14990 924 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14991 488 case ewRock: tempguy.firesfx = 51; break;
14992 904 case ewMagic: tempguy.firesfx = 32; break;
14993 79 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14994 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14995 135 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14996 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14997 359 case ewFireTrail: tempguy.firesfx = 13; break;
14998 751 case ewFlame: tempguy.firesfx = 13; break;
14999 105 case ewWind: tempguy.firesfx = 32; break;
15000 79 case ewFlame2: tempguy.firesfx = 13; break;
15001 case ewFlame2Trail: tempguy.firesfx = 13; break;
15002 case ewIce: tempguy.firesfx = 44; break;
15003 759 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
15004
15005 //what about special attacks (e.g. summoning == 56)
15006 default: break; //No assign.
15007 }
15008 38912 }
15009 38912 }
15010
15011 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
15012
4/6
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14848 times.
53760 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
15013 {
15014
2/2
✓ Branch 0 taken 3527 times.
✓ Branch 1 taken 35385 times.
38912 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
15015 38912 }
15016 //Keese and bat halt rates.
15017
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
53760 if ( guyversion < 42 && guy_cversion < 4 )
15018 {
15019
15020
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 524 times.
38912 if ( tempguy.family == eeKEESE )
15021 {
15022
15023
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 322 times.
524 if ( !tempguy.misc1 )
15024 {
15025 322 tempguy.misc16 = 120;
15026 322 tempguy.misc17 = 16;
15027
15028 322 }
15029 524 }
15030
2/2
✓ Branch 0 taken 38747 times.
✓ Branch 1 taken 165 times.
38912 if ( tempguy.family == eePEAHAT )
15031 {
15032 165 tempguy.misc16 = 80;
15033 165 tempguy.misc17 = 16;
15034 165 }
15035
2/2
✓ Branch 0 taken 38836 times.
✓ Branch 1 taken 76 times.
38912 if ( tempguy.family == eeGHINI )
15036 {
15037 76 tempguy.misc16 = 120;
15038 76 tempguy.misc17 = 10;
15039 76 }
15040
15041
15042 38912 }
15043
15044
15045 //miscellaneous other corrections
15046 //fix the mirror wizzrobe -DD
15047
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 7)
15048 {
15049 if(i == eMWIZ)
15050 {
15051 tempguy.misc2 = 0;
15052 tempguy.misc4 = 1;
15053 }
15054 }
15055
15056
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 8)
15057 {
15058 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15059 {
15060 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15061 tempguy.misc5 = 4; //neck length in segments
15062 tempguy.misc6 = 8; //neck offset from first body tile
15063 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15064 tempguy.misc8 = 168; //head offset from first body tile
15065 tempguy.misc9 = 228; //flying head offset from first body tile
15066
15067 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15068 {
15069 tempguy.misc6 += 10; //neck offset from first body tile
15070 tempguy.misc8 -= 12; //head offset from first body tile
15071 }
15072 }
15073 }
15074
15075
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15076 {
15077 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15078 tempguy.bosspal = spDIG;
15079 }
15080
15081
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 11) // December 2007 - Spinning Tile fix
15082 {
15083 if(tempguy.family==eeSPINTILE)
15084 {
15085 tempguy.flags |= guy_superman;
15086 tempguy.item_set = 0; // Don't drop items
15087 tempguy.step = 300;
15088 }
15089 }
15090
15091
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15092 {
15093 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15094 {
15095 if(tempguy.family==eeROPE)
15096 {
15097 tempguy.flags2 &= ~guy_flashing;
15098 }
15099 }
15100
15101 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15102 {
15103 if(tempguy.family==eeBUBBLE)
15104 {
15105 tempguy.flags2 &= ~guy_flashing;
15106 }
15107 }
15108
15109 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15110 {
15111 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15112 {
15113 tempguy.flags2 |= guy_blinking;
15114 }
15115
15116 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15117 {
15118 tempguy.flags2 |= guy_transparent;
15119 }
15120 }
15121 }
15122
15123
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15124 {
15125 if(i==gFIRE)
15126 {
15127 tempguy.e_anim = aFLIP;
15128 tempguy.e_frate = 24;
15129 }
15130
15131 if(i==gFAIRY)
15132 {
15133 tempguy.e_anim = a2FRM;
15134 tempguy.e_frate = 16;
15135 }
15136 }
15137
15138
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15139 {
15140 if(i==0) Z_message("Updating guys to version 16...\n");
15141
15142 update_guy_1(&tempguy);
15143
15144 if(i==eMPOLSV)
15145 {
15146 tempguy.defense[edefARROW] = edCHINK;
15147 tempguy.defense[edefMAGIC] = ed1HKO;
15148 tempguy.defense[edefREFMAGIC] = ed1HKO;
15149 }
15150 }
15151
15152
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 17) // December 2009
15153 {
15154 if(tempguy.family==eePROJECTILE)
15155 {
15156 tempguy.misc1 = 0;
15157 }
15158 }
15159
15160
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 18) // January 2010
15161 {
15162 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15163 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15164
15165 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15166 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15167
15168 if(tempguy.family == eeAQUA)
15169 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15170 else if(tempguy.family == eeMANHAN)
15171 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15172 else if(tempguy.family==eePATRA)
15173 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15174 else if(tempguy.family==eeGHOMA)
15175 {
15176 for(int32_t j=0; j<edefLAST; j++)
15177 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15178
15179 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15180
15181 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15182
15183 tempguy.misc1--;
15184 }
15185 else if(tempguy.family == eeGLEEOK)
15186 {
15187 for(int32_t j=0; j<edefLAST; j++)
15188 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15189
15190 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15191 }
15192 else if(tempguy.family == eeARMOS)
15193 {
15194 tempguy.family=eeWALK;
15195 tempguy.hrate = 0;
15196 tempguy.misc10 = tempguy.misc1;
15197 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15198 tempguy.misc9 = e9tARMOS;
15199 }
15200 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15201 {
15202 tempguy.family=eeWALK;
15203 tempguy.hrate = 0;
15204 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15205 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15206 }
15207
15208 // Spawn animation flags
15209 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15210 tempguy.flags |= guy_fadeflicker;
15211 else
15212 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15213 }
15214
15215
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 20) // April 2010
15216 {
15217 if(tempguy.family == eeTRAP)
15218 {
15219 tempguy.misc2 = tempguy.misc10;
15220
15221 if(tempguy.misc10>=1)
15222 {
15223 tempguy.misc1++;
15224 }
15225
15226 tempguy.misc10 = 0;
15227 }
15228
15229 // Bomb Blast fix
15230 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15231 tempguy.weapon = ewLitBomb;
15232 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15233 tempguy.weapon = ewLitSBomb;
15234 }
15235
15236
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 21) // September 2011
15237 {
15238 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15239 {
15240 if(tempguy.family == eeKEESETRIB)
15241 {
15242 tempguy.family = eeKEESE;
15243 tempguy.misc2 = e2tKEESETRIB;
15244 tempguy.misc1 = 0;
15245 }
15246
15247 tempguy.rate = 2;
15248 tempguy.hrate = 8;
15249 tempguy.homing = 0;
15250 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15251 }
15252 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15253 {
15254 if(tempguy.family == eePEAHAT)
15255 {
15256 tempguy.rate = 4;
15257 tempguy.step = 62;
15258 }
15259 else
15260 tempguy.step = 25;
15261
15262 tempguy.hrate = 8;
15263 tempguy.homing = 0;
15264 }
15265 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15266 {
15267 if(tempguy.family == eeMANHAN)
15268 tempguy.step=50;
15269
15270 tempguy.hrate = 16;
15271 tempguy.homing = 0;
15272 }
15273 else if(tempguy.family == eeGLEEOK)
15274 {
15275 tempguy.rate = 2;
15276 tempguy.homing = 0;
15277 tempguy.hrate = 9;
15278 tempguy.step=89;
15279 }
15280 else if(tempguy.family == eeGHINI)
15281 {
15282 tempguy.rate = 4;
15283 tempguy.hrate = 12;
15284 tempguy.step=62;
15285 tempguy.homing = 0;
15286 }
15287
15288 // Bigdig random rate fix
15289 if(tempguy.family==eeDIG && tempguy.misc10==1)
15290 {
15291 tempguy.rate = 2;
15292 }
15293 }
15294
15295
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 24) // November 2012
15296 {
15297 if(tempguy.family==eeLANM)
15298 tempguy.misc3 = 1;
15299 else if(tempguy.family==eeMOLD)
15300 tempguy.misc2 = 0;
15301 }
15302
15303
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15304 {
15305
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 38258 times.
38912 if(tempguy.family!=eeDIG)
15306 {
15307 38258 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15308 38258 }
15309
15310 38912 }
15311 // does not seem to solve the issue!
15312
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if ( Header->zelda_version <= 0x210 )
15313 {
15314 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15315 if ( tempguy.family == eeDONGO )
15316 {
15317 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15318 }
15319 }
15320
15321
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion >= 42)
15322 {
15323
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 1024 times.
14848 if(guyversion >= 47)
15324 {
15325
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15326 {
15327 return qe_invalid;
15328 }
15329 13824 }
15330 else
15331 {
15332 byte fl;
15333
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15334 {
15335 return qe_invalid;
15336 }
15337 1024 tempguy.moveflags = fl;
15338 }
15339 14848 }
15340 else
15341 {
15342
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30458 times.
✓ Branch 2 taken 1192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 275 times.
✓ Branch 6 taken 239 times.
✓ Branch 7 taken 5787 times.
38912 switch(tempguy.family)
15343 {
15344 //No gravity; floats over pits
15345 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15346 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15347 //Special (bosses, etc)
15348 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15349 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15350 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15351 30458 tempguy.moveflags = FLAG_CAN_PITWALK;
15352 30458 break;
15353 //No gravity, but falls in pits
15354 case eeLEV:
15355 515 tempguy.moveflags = FLAG_CAN_PITFALL;
15356 515 break;
15357 //Bosses that respect pits
15358 case eeDONGO:
15359 275 tempguy.moveflags = FLAG_OBEYS_GRAV;
15360 275 break;
15361 case eeLANM:
15362 239 tempguy.moveflags = 0;
15363 239 break;
15364 //Gravity, floats over pits
15365 case eeWIZZ: case eeWALLM: case eeGHINI:
15366 1192 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15367 1192 break;
15368 //Gravity and falls in pits
15369 case eeWALK:
15370
4/4
✓ Branch 0 taken 5469 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 5191 times.
5787 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15371 596 break;
15372 [[fallthrough]];
15373 case eeOTHER:
15374 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15375 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15376 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15377 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15378 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15379 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15380 5637 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15381 5637 }
15382 }
15383
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 43)
15384 {
15385
2/2
✓ Branch 0 taken 31650 times.
✓ Branch 1 taken 7262 times.
38912 switch(tempguy.family)
15386 {
15387 //No gravity; floats over pits
15388 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15389 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15390 //Special (bosses, etc)
15391 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15392 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15393 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15394 case eeWIZZ: case eeWALLM: case eeGHINI:
15395 //Gravity, floats over pits
15396 31650 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15397 31650 break;
15398 }
15399 38912 }
15400
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if (guyversion < 44)
15401 {
15402
2/2
✓ Branch 0 taken 38546 times.
✓ Branch 1 taken 366 times.
38912 if ( tempguy.family == eeGHOMA )
15403 {
15404 366 tempguy.flags |= guy_fadeinstant;
15405 366 }
15406 38912 }
15407
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if (guyversion > 44)
15408 {
15409
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15410 {
15411 return qe_invalid;
15412 }
15413
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15414 {
15415 return qe_invalid;
15416 }
15417
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15418 {
15419 return qe_invalid;
15420 }
15421 14848 }
15422 else
15423 {
15424
2/2
✓ Branch 0 taken 38761 times.
✓ Branch 1 taken 151 times.
38912 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15425 38912 tempguy.spr_death = iwDeath;
15426 38912 tempguy.spr_spawn = iwSpawn;
15427 }
15428
15429
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 46)
15430 {
15431
4/4
✓ Branch 0 taken 5787 times.
✓ Branch 1 taken 33125 times.
✓ Branch 2 taken 5469 times.
✓ Branch 3 taken 318 times.
38912 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15432 {
15433 318 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15434 318 }
15435 38912 }
15436
15437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(keepdata)
15438 {
15439 53760 guysbuf[i] = tempguy;
15440 53760 }
15441 53760 }
15442 105 }
15443
15444 105 return 0;
15445 114 }
15446
15447 void update_guy_1(guydata *tempguy) // November 2009
15448 {
15449 bool doesntcount = false;
15450 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15451
15452 switch(tempguy->family)
15453 {
15454 case 1: //eeWALK
15455 switch(tempguy->misc10)
15456 {
15457 case 0: //Stalfos
15458 if(tempguy->misc1==1) // Fires four projectiles at once
15459 tempguy->misc1=4;
15460
15461 break;
15462
15463 case 1: //Darknut
15464 goto darknuts;
15465 break;
15466 }
15467
15468 tempguy->misc10 = 0;
15469 break;
15470
15471 case 2: //eeSHOOT
15472 tempguy->family = eeWALK;
15473
15474 switch(tempguy->misc10)
15475 {
15476 case 0: //Octorok
15477 if(tempguy->misc1==1||tempguy->misc1==2)
15478 {
15479 tempguy->misc1=e1tFIREOCTO;
15480 tempguy->misc2=e2tFIREOCTO;
15481 }
15482 else tempguy->misc1 = 0;
15483
15484 tempguy->misc6=tempguy->misc4;
15485 tempguy->misc4=tempguy->misc3;
15486 tempguy->misc3=0;
15487 break;
15488
15489 case 1: // Moblin
15490 tempguy->misc1 = 0;
15491 break;
15492
15493 case 2: //Lynel
15494 tempguy->misc6=tempguy->misc1+1;
15495 tempguy->misc1=0;
15496 break;
15497
15498 case 3: //Stalfos 2
15499 if(tempguy->misc1==1) // Fires four projectiles at once
15500 tempguy->misc1=e1t4SHOTS;
15501 else tempguy->misc1 = 0;
15502
15503 break;
15504
15505 case 4: //Darknut 5
15506 darknuts:
15507 tempguy->defense[edefFIRE] = edIGNORE;
15508 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15509 tempguy->defense[edefHOOKSHOT] = 0;
15510 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15511 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15512
15513 if(tempguy->misc1==1)
15514 tempguy->misc1=2;
15515 else if(tempguy->misc1==2)
15516 {
15517 tempguy->misc4=tempguy->misc3;
15518 tempguy->misc3=tempguy->misc2;
15519 tempguy->misc2=e2tSPLIT;
15520 tempguy->misc1 = 0;
15521 }
15522 else tempguy->misc1 = 0;
15523
15524 tempguy->flags |= inv_front;
15525
15526 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15527 tempguy->flags |= guy_bkshield;
15528
15529 break;
15530 }
15531
15532 tempguy->misc10 = 0;
15533 break;
15534
15535 /*
15536 case 9: //eeARMOS
15537 tempguy->family = eeWALK;
15538 break;
15539 */
15540 case 11: //eeGEL
15541 case 33: //eeGELTRIB
15542 if(tempguy->family==33)
15543 {
15544 tempguy->misc4 = 1;
15545
15546 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15547 tempguy->misc3 = tempguy->misc2;
15548
15549 tempguy->misc2 = e2tTRIBBLE;
15550 }
15551 else
15552 {
15553 tempguy->misc4 = 0;
15554 tempguy->misc3 = 0;
15555 tempguy->misc2 = 0;
15556 }
15557
15558 tempguy->family = eeWALK;
15559
15560 if(tempguy->misc1)
15561 {
15562 tempguy->misc1=1;
15563 tempguy->weapon = ewFireTrail;
15564 }
15565
15566 break;
15567
15568 case 34: //eeZOLTRIB
15569 case 12: //eeZOL
15570 tempguy->misc4=tempguy->misc3;
15571 tempguy->misc3=tempguy->misc2;
15572 tempguy->family = eeWALK;
15573 tempguy->misc2=e2tSPLITHIT;
15574
15575 if(tempguy->misc1)
15576 {
15577 tempguy->misc1=1;
15578 tempguy->weapon = ewFireTrail;
15579 }
15580
15581 break;
15582
15583 case 13: //eeROPE
15584 tempguy->family = eeWALK;
15585 tempguy->misc9 = e9tROPE;
15586
15587 if(tempguy->misc1)
15588 {
15589 tempguy->misc4 = tempguy->misc3;
15590 tempguy->misc3 = tempguy->misc2;
15591 tempguy->misc2 = e2tBOMBCHU;
15592 }
15593
15594 tempguy->misc1 = 0;
15595 break;
15596
15597 case 14: //eeGORIYA
15598 tempguy->family = eeWALK;
15599
15600 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15601
15602 break;
15603
15604 case 17: //eeBUBBLE
15605 tempguy->family = eeWALK;
15606 tempguy->misc8 = tempguy->misc2;
15607 tempguy->misc7 = tempguy->misc1 + 1;
15608 tempguy->misc1 = tempguy->misc2 = 0;
15609
15610 //fallthrogh
15611 case eeTRAP:
15612 case eeROCK:
15613 doesntcount = true;
15614 break;
15615
15616 case 35: //eeVIRETRIB
15617 case 18: //eeVIRE
15618 tempguy->family = eeWALK;
15619 tempguy->misc4=tempguy->misc3;
15620 tempguy->misc3=tempguy->misc2;
15621 tempguy->misc2=e2tSPLITHIT;
15622 tempguy->misc9=e9tVIRE;
15623 break;
15624
15625 case 19: //eeLIKE
15626 tempguy->family = eeWALK;
15627 tempguy->misc7 = e7tEATITEMS;
15628 tempguy->misc8=95;
15629 break;
15630
15631 case 20: //eePOLSV
15632 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15633 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15634 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15635 tempguy->defense[edefARROW] = ed1HKO;
15636 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15637 tempguy->family = eeWALK;
15638 tempguy->misc9 = e9tPOLSVOICE;
15639 tempguy->rate = 4;
15640 tempguy->homing = 32;
15641 tempguy->hrate = 10;
15642 tempguy->grumble = 0;
15643 break;
15644
15645 case eeWIZZ:
15646 if(tempguy->misc4)
15647 {
15648 for(int32_t i=0; i < edefLAST; i++)
15649 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15650 }
15651 else
15652 {
15653 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15654 tempguy->defense[edefMAGIC] = edCHINK;
15655 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15656 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15657 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15658 }
15659
15660 break;
15661
15662 case eePEAHAT:
15663 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15664
15665 if(!(tempguy->flags & guy_bhit))
15666 tempguy->defense[edefBRANG] = edSTUNONLY;
15667
15668 break;
15669
15670 case eeLEV:
15671 tempguy->defense[edefSTOMP] = edCHINK;
15672 break;
15673 }
15674
15675 // Old flags
15676 if(tempguy->flags & guy_superman)
15677 {
15678 for(int32_t i = 0; i < edefLAST; i++)
15679 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15680 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15681 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15682 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15683 }
15684
15685 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15686
15687 if(doesntcount)
15688 tempguy->flags |= (guy_doesntcount);
15689 }
15690
15691
15692 187744 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15693 {
15694 byte tempbyte, padding;
15695 int32_t extras, secretcombos;
15696 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->valid),f,true))
15698 {
15699 return qe_invalid;
15700 }
15701
15702
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->guy),f,true))
15704 {
15705 return qe_invalid;
15706 }
15707
15708
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15709 {
15710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15711 {
15712 return qe_invalid;
15713 }
15714
15715 6864 temp_mapscr->str=tempbyte;
15716 6864 }
15717 else
15718 {
15719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->str),f,true))
15720 {
15721 return qe_invalid;
15722 }
15723 }
15724
15725
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->room),f,true))
15726 {
15727 return qe_invalid;
15728 }
15729
15730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->item),f,true))
15731 {
15732 return qe_invalid;
15733 }
15734
15735
3/6
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153000 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15736 {
15737 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15738 34744 }
15739 else
15740 {
15741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15742 return qe_invalid;
15743 }
15744
15745
2/4
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version < 0x192)||
15746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15747 {
15748
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15749 {
15750 return qe_invalid;
15751 }
15752 6864 }
15753
15754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15755 {
15756 return qe_invalid;
15757 }
15758
15759
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15760 {
15761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15762 {
15763 return qe_invalid;
15764 }
15765 6864 }
15766
15767
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15768 {
15769
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15770 {
15771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15772 {
15773 return qe_invalid;
15774 }
15775 459000 }
15776 153000 }
15777 else
15778 {
15779 34744 temp_mapscr->tilewarptype[1]=0;
15780 34744 temp_mapscr->tilewarptype[2]=0;
15781 34744 temp_mapscr->tilewarptype[3]=0;
15782 }
15783
15784
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15785 {
15786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15787 {
15788 return qe_invalid;
15789 }
15790 180880 }
15791
15792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15793 {
15794 return qe_invalid;
15795 }
15796
15797 187744 temp_mapscr->warpreturnx[1]=0;
15798 187744 temp_mapscr->warpreturnx[2]=0;
15799 187744 temp_mapscr->warpreturnx[3]=0;
15800
15801
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15802 {
15803
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15804 {
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15806 {
15807 return qe_invalid;
15808 }
15809 459000 }
15810 153000 }
15811
15812
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15813 {
15814 return qe_invalid;
15815 }
15816
15817 187744 temp_mapscr->warpreturny[1]=0;
15818 187744 temp_mapscr->warpreturny[2]=0;
15819 187744 temp_mapscr->warpreturny[3]=0;
15820
15821
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15822 {
15823
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15824 {
15825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15826 {
15827 return qe_invalid;
15828 }
15829 459000 }
15830
15831
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(version>=18)
15832 {
15833
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15834 {
15835 return qe_invalid;
15836 }
15837 153000 }
15838 else
15839 {
15840 byte temp;
15841
15842 if(!p_getc(&temp,f,true))
15843 {
15844 return qe_invalid;
15845 }
15846
15847 temp_mapscr->warpreturnc=temp<<8|temp;
15848 }
15849 153000 }
15850
15851
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->stairx),f,true))
15852
15853 {
15854 return qe_invalid;
15855 }
15856
15857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->stairy),f,true))
15858 {
15859 return qe_invalid;
15860 }
15861
15862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemx),f,true))
15863 {
15864 return qe_invalid;
15865 }
15866
15867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemy),f,true))
15868 {
15869 return qe_invalid;
15870 }
15871
15872
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version > 15) // February 2009
15873 {
15874
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->color),f,true))
15875 {
15876 return qe_invalid;
15877 }
15878 153000 }
15879 else
15880 {
15881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15882 {
15883 return qe_invalid;
15884 }
15885
15886 34744 temp_mapscr->color = (word) tempbyte;
15887 }
15888
15889
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15890 {
15891 return qe_invalid;
15892 }
15893
15894
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
15895 {
15896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15897 {
15898 return qe_invalid;
15899
15900 }
15901 750976 }
15902
15903
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
15904 {
15905
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
15906 {
15907 return qe_invalid;
15908 }
15909
15910 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15911
15912
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15913 {
15914 for(int32_t i=1; i<4; i++)
15915 {
15916 if(!p_getc(&(tempbyte),f,true))
15917 {
15918 return qe_invalid;
15919 }
15920
15921 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15922 }
15923 }
15924 else
15925 {
15926 34744 temp_mapscr->tilewarpdmap[1]=0;
15927 34744 temp_mapscr->tilewarpdmap[2]=0;
15928 34744 temp_mapscr->tilewarpdmap[3]=0;
15929 }
15930 34744 }
15931 else
15932 {
15933
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
15934 {
15935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15936 {
15937 return qe_invalid;
15938 }
15939 612000 }
15940 }
15941
15942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15943 {
15944 return qe_invalid;
15945 }
15946
15947
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15948 {
15949
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15950 {
15951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15952 {
15953 return qe_invalid;
15954 }
15955 459000 }
15956 153000 }
15957 else
15958 {
15959 34744 temp_mapscr->tilewarpscr[1]=0;
15960 34744 temp_mapscr->tilewarpscr[2]=0;
15961 34744 temp_mapscr->tilewarpscr[3]=0;
15962 }
15963
15964
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
15965 {
15966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15967 {
15968 return qe_invalid;
15969 }
15970 153000 }
15971 else
15972 {
15973 34744 temp_mapscr->tilewarpoverlayflags=0;
15974 }
15975
15976
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15977 {
15978 return qe_invalid;
15979 }
15980
15981
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15982 {
15983
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15984 {
15985 return qe_invalid;
15986 }
15987
15988 6864 }
15989
15990
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15991 {
15992 if(!p_getc(&padding,f,true))
15993 {
15994 return qe_invalid;
15995 }
15996 }
15997
15998
2/2
✓ Branch 0 taken 1877440 times.
✓ Branch 1 taken 187744 times.
2065184 for(int32_t k=0; k<10; k++)
15999 {
16000 /*
16001 if (!temp_mapscr->enemy[k])
16002 {
16003 continue;
16004 }
16005 */
16006
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
16007 {
16008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16009 {
16010 return qe_invalid;
16011 }
16012
16013 68640 temp_mapscr->enemy[k]=tempbyte;
16014 68640 }
16015 else
16016 {
16017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1808800 times.
1808800 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
16018 {
16019 return qe_invalid;
16020 }
16021 }
16022
16023
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16024 {
16025 //using enumerations here is dangerous
16026 //very easy to break old quests -DD
16027
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16028 {
16029 788 temp_mapscr->enemy[k]+=5;
16030 788 }
16031
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16032 {
16033 40 temp_mapscr->enemy[k]+=1;
16034 40 }
16035 68640 }
16036
16037
2/2
✓ Branch 0 taken 1530000 times.
✓ Branch 1 taken 347440 times.
1877440 if(version < 9)
16038 {
16039
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
16040 {
16041 29025 temp_mapscr->enemy[k]+=10;
16042 29025 }
16043 347440 }
16044 //don't read in any invalid data
16045
2/2
✓ Branch 0 taken 1877420 times.
✓ Branch 1 taken 20 times.
1877440 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16046 {
16047 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16048 20 temp_mapscr->enemy[k] = 0;
16049 20 }
16050 1877440 }
16051
16052
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->pattern),f,true))
16053 {
16054 return qe_invalid;
16055 }
16056
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16063 {
16064
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
16065 {
16066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16067 {
16068 return qe_invalid;
16069 }
16070 459000 }
16071 153000 }
16072 else
16073 {
16074 34744 temp_mapscr->sidewarptype[1]=0;
16075 34744 temp_mapscr->sidewarptype[2]=0;
16076 34744 temp_mapscr->sidewarptype[3]=0;
16077 }
16078
16079
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
16080 {
16081
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16082 {
16083 return qe_invalid;
16084 }
16085 153000 }
16086 else
16087 {
16088 34744 temp_mapscr->sidewarpoverlayflags=0;
16089 }
16090
16091
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16092 {
16093 return qe_invalid;
16094 }
16095
16096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16097 {
16098 return qe_invalid;
16099 }
16100
16101
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
16102 {
16103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16104 {
16105 return qe_invalid;
16106 }
16107 750976 }
16108
16109
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16110 {
16111 return qe_invalid;
16112 }
16113
16114
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16115 {
16116
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 459000 times.
612000 for(int32_t i=1; i<4; i++)
16117 {
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16119 {
16120 return qe_invalid;
16121 }
16122 459000 }
16123 153000 }
16124 else
16125 {
16126 34744 temp_mapscr->sidewarpscr[1]=0;
16127 34744 temp_mapscr->sidewarpscr[2]=0;
16128 34744 temp_mapscr->sidewarpscr[3]=0;
16129 }
16130
16131
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
16132 {
16133
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16134 {
16135 return qe_invalid;
16136 }
16137
16138 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16139
16140
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16141 {
16142 for(int32_t i=1; i<4; i++)
16143 {
16144 if(!p_getc(&(tempbyte),f,true))
16145 {
16146 return qe_invalid;
16147 }
16148
16149 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16150 }
16151 }
16152 else
16153 {
16154 34744 temp_mapscr->sidewarpdmap[1]=0;
16155 34744 temp_mapscr->sidewarpdmap[2]=0;
16156 34744 temp_mapscr->sidewarpdmap[3]=0;
16157 }
16158 34744 }
16159 else
16160 {
16161
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
16162 {
16163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16164 {
16165 return qe_invalid;
16166 }
16167 612000 }
16168 }
16169
16170
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16171 {
16172
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16173 {
16174 return qe_invalid;
16175 }
16176 153000 }
16177 34744 else temp_mapscr->sidewarpindex = 0;
16178
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16180 {
16181 return qe_invalid;
16182 }
16183
16184
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
16185 {
16186
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16187 {
16188 return qe_invalid;
16189 }
16190 6864 }
16191
16192
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16193 {
16194 return qe_invalid;
16195 }
16196
16197
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16198 {
16199 return qe_invalid;
16200 }
16201
16202
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->flags),f,true))
16203 {
16204 return qe_invalid;
16205 }
16206
16207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags2),f,true))
16208 {
16209 return qe_invalid;
16210 }
16211
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags3),f,true))
16213 {
16214 return qe_invalid;
16215 }
16216
16217
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16218 //if (version>2)
16219 {
16220
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags4),f,true))
16221 {
16222 return qe_invalid;
16223 }
16224 153000 }
16225
16226
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16227 {
16228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags5),f,true))
16229 {
16230 return qe_invalid;
16231 }
16232
16233
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16234 {
16235 return qe_invalid;
16236 }
16237
16238
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16239 {
16240 return qe_invalid;
16241 }
16242
16243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(temp_mapscr->flags5&32)
16244 {
16245 temp_mapscr->flags5 &= ~32;
16246 temp_mapscr->noreset |= 48;
16247 }
16248
16249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(version<8)
16250 {
16251 if(temp_mapscr->noreset&1)
16252 {
16253 temp_mapscr->noreset|=8192;
16254 }
16255
16256 if(temp_mapscr->nocarry&1)
16257 {
16258 temp_mapscr->nocarry|=8192;
16259 temp_mapscr->nocarry&=~1;
16260 }
16261 }
16262 153000 }
16263 else
16264 {
16265 34744 temp_mapscr->flags5 = 0;
16266 34744 temp_mapscr->noreset = 0;
16267 34744 temp_mapscr->nocarry = 0;
16268 }
16269
16270
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16271 {
16272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags6),f,true))
16273 {
16274 return qe_invalid;
16275 }
16276 153000 }
16277
16278
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>5)
16279 {
16280
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags7),f,true))
16281 {
16282 return qe_invalid;
16283 }
16284
16285
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags8),f,true))
16286 {
16287 return qe_invalid;
16288 }
16289
16290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags9),f,true))
16291 {
16292 return qe_invalid;
16293 }
16294
16295
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags10),f,true))
16296 {
16297 return qe_invalid;
16298 }
16299
16300
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16301 {
16302 return qe_invalid;
16303 }
16304 153000 }
16305 else
16306 {
16307 34744 temp_mapscr->csensitive=1;
16308 }
16309
16310
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<14) // August 2007: screen SFX added
16311 {
16312
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16313 {
16314 100 temp_mapscr->bosssfx=
16315
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16316 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16317 WAV_ROAR;
16318 100 }
16319
16320
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16321 {
16322 91 temp_mapscr->oceansfx=WAV_SEA;
16323 91 }
16324
16325 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16326 ? 0 : WAV_SECRET;
16327
16328 34744 temp_mapscr->flags3 &= ~66; //64|2
16329 34744 temp_mapscr->flags2 &= ~32;
16330 34744 temp_mapscr->flags &= ~136; // 128|8
16331 34744 }
16332 else
16333 {
16334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16335 {
16336 return qe_invalid;
16337 }
16338
16339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16340 {
16341 return qe_invalid;
16342 }
16343
16344
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16345 {
16346 return qe_invalid;
16347 }
16348 }
16349
16350
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<15) // October 2007: another SFX
16351 {
16352 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16353 34744 }
16354 else
16355 {
16356
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16357 {
16358 return qe_invalid;
16359 }
16360 }
16361
16362
16363
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16364 {
16365
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16366 {
16367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16368 {
16369 return qe_invalid;
16370 }
16371 1085280 }
16372
16373
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 1085280 times.
1266160 for(int32_t k=0; k<6; k++)
16374 {
16375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16376 {
16377 return qe_invalid;
16378 }
16379 1085280 }
16380 180880 }
16381
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16382 {
16383 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16384 {
16385 return qe_invalid;
16386 }
16387
16388 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16389 {
16390 return qe_invalid;
16391 }
16392
16393 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16394 {
16395 return qe_invalid;
16396 }
16397
16398 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16399
16400 {
16401 return qe_invalid;
16402 }
16403 }
16404
16405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>149))
16406 {
16407 for(int32_t k=0; k<6; k++)
16408 {
16409 if(!p_getc(&tempbyte,f,true)) //layerxsize
16410 {
16411 return qe_invalid;
16412 }
16413 }
16414
16415 for(int32_t k=0; k<6; k++)
16416 {
16417 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16418 {
16419 return qe_invalid;
16420 }
16421 }
16422
16423 for(int32_t k=0; k<6; k++)
16424 {
16425 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16426 {
16427 return qe_invalid;
16428 }
16429 }
16430
16431 for(int32_t k=0; k<6; k++)
16432 {
16433 if(!p_getc(&tempbyte,f,true)) //layerysize
16434 {
16435 return qe_invalid;
16436 }
16437 }
16438
16439 for(int32_t k=0; k<6; k++)
16440 {
16441 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16442 {
16443 return qe_invalid;
16444 }
16445 }
16446
16447 for(int32_t k=0; k<6; k++)
16448 {
16449 if(!p_getc(&tempbyte,f,true)) //layerydelay
16450 {
16451 return qe_invalid;
16452 }
16453 }
16454 }
16455
16456
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16457 {
16458
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16459 {
16460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16461 {
16462 return qe_invalid;
16463 }
16464 1085280 }
16465 180880 }
16466
16467
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16468 {
16469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 if((Header->zelda_version == 0x192)&&(Header->build>153))
16470 {
16471 if(!p_getc(&padding,f,true))
16472 {
16473 return qe_invalid;
16474 }
16475 }
16476
16477
1/2
✓ Branch 0 taken 180880 times.
✗ Branch 1 not taken.
180880 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16478 {
16479 return qe_invalid;
16480 }
16481 180880 }
16482
16483
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16484 {
16485 6864 extras=15;
16486 6864 }
16487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16488 {
16489 extras=11;
16490 }
16491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16492 {
16493 extras=32;
16494 }
16495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16496 {
16497 extras=64;
16498 }
16499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 else if(Header->zelda_version < 0x193)
16500 {
16501 extras=62;
16502 }
16503 else
16504
16505 {
16506 180880 extras=0;
16507 }
16508
16509
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 187744 times.
290704 for(int32_t k=0; k<extras; k++)
16510 {
16511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16512 {
16513 return qe_invalid;
16514 }
16515 102960 }
16516
16517
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16518 //if (version>3)
16519 {
16520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16521 {
16522 return qe_invalid;
16523 }
16524
16525
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16526 {
16527 return qe_invalid;
16528 }
16529 153000 }
16530 else
16531 {
16532 34744 temp_mapscr->nextmap=0;
16533 34744 temp_mapscr->nextscr=0;
16534 }
16535
16536
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16537 {
16538 6864 secretcombos=20;
16539 6864 }
16540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16541 {
16542 secretcombos=256;
16543 }
16544 else
16545 {
16546 180880 secretcombos=128;
16547 }
16548
16549
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16550 {
16551
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16552 {
16553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16554 {
16555 return qe_invalid;
16556 }
16557
16558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16559 {
16560 137280 temp_mapscr->secretcombo[k]=tempbyte;
16561 137280 }
16562 137280 }
16563 6864 }
16564 else
16565 {
16566
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16567 {
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16569 {
16570 return qe_invalid;
16571 }
16572
16573 23152640 }
16574 }
16575
16576
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16577 {
16578
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16579 {
16580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16581 {
16582 return qe_invalid;
16583 }
16584 23152640 }
16585
16586
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16587 {
16588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16589 {
16590 return qe_invalid;
16591 }
16592 23152640 }
16593 180880 }
16594
16595
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16596 {
16597 if(!p_getc(&padding,f,true))
16598 {
16599 return qe_invalid;
16600 }
16601 }
16602
16603 187744 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16604
16605
2/2
✓ Branch 0 taken 33042944 times.
✓ Branch 1 taken 187744 times.
33230688 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16606 {
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33042944 times.
33042944 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16608 {
16609 return qe_invalid;
16610 }
16611 33042944 }
16612
16613
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16614 {
16615 if(!p_getc(&padding,f,true))
16616 {
16617 return qe_invalid;
16618 }
16619
16620 if(!p_getc(&padding,f,true))
16621 {
16622 return qe_invalid;
16623 }
16624 }
16625
16626
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16627 {
16628
2/2
✓ Branch 0 taken 31834880 times.
✓ Branch 1 taken 180880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16629 {
16630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16631 {
16632 return qe_invalid;
16633 }
16634
16635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31834880 if((Header->zelda_version == 0x192)&&(Header->build<24))
16636 {
16637 if(!p_getc(&tempbyte,f,true))
16638 {
16639 return qe_invalid;
16640 }
16641
16642 if(!p_getc(&tempbyte,f,true))
16643 {
16644 return qe_invalid;
16645 }
16646
16647 if(!p_getc(&tempbyte,f,true))
16648 {
16649 return qe_invalid;
16650 }
16651 }
16652 31834880 }
16653 180880 }
16654
16655
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16656 {
16657
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 31834880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16658 {
16659
16660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16661 {
16662 return qe_invalid;
16663 }
16664 31834880 }
16665 180880 }
16666
16667
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16668 {
16669 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16670 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16671 6864 }
16672
16673
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16674 {
16675 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16676 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16677 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16678 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16679 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16680 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16681 6864 }
16682
16683
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16684 {
16685
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16686 {
16687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16688 {
16689 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16690 {
16691 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16692 }
16693 }
16694 else
16695 {
16696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16697 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16698 {
16699 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16700 1208064 }
16701
16702 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16703 }
16704
16705 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16706 1208064 }
16707 6864 }
16708
16709 /*if(version>12)
16710 {
16711 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16712 {
16713 return qe_invalid;
16714 }
16715 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16716 {
16717 return qe_invalid;
16718 }
16719 }*/
16720
16721
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>4)
16722 {
16723
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16724 {
16725 return qe_invalid;
16726 }
16727 153000 }
16728 else
16729 {
16730 34744 temp_mapscr->screen_midi = -1;
16731 }
16732
16733
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>=17)
16734 {
16735
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16736 {
16737 return qe_invalid;
16738 }
16739 153000 }
16740 else
16741 {
16742 34744 temp_mapscr->lens_layer = llNORMAL;
16743 }
16744
16745
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version>6)
16746 {
16747 dword bits;
16748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_igetl(&bits,f,true))
16749 {
16750 return qe_invalid;
16751 }
16752
16753 int32_t m;
16754 float tempfloat;
16755 word tempw;
16756 153000 temp_mapscr->ffcCountMarkDirty();
16757
16758
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 4896000 times.
5049000 for(m=0; m<32; m++)
16759 {
16760 4896000 ffcdata& tempffc = temp_mapscr->ffcs[m];
16761 4896000 tempffc.clear();
16762
2/2
✓ Branch 0 taken 4873014 times.
✓ Branch 1 taken 22986 times.
4896000 if((bits>>m)&1)
16763 {
16764
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetw(&tempw,f,true))
16765 {
16766 return qe_invalid;
16767 }
16768 22986 tempffc.setData(tempw);
16769
16770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.cset),f,true))
16771 {
16772 return qe_invalid;
16773 }
16774
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.delay),f,true))
16776 {
16777 return qe_invalid;
16778 }
16779
16780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(version < 9)
16781 {
16782 if(!p_igetf(&tempfloat,f,true))
16783 {
16784 return qe_invalid;
16785 }
16786
16787 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16788
16789 if(!p_igetf(&tempfloat,f,true))
16790 {
16791 return qe_invalid;
16792 }
16793
16794 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16795
16796 if(!p_igetf(&tempfloat,f,true))
16797 {
16798 return qe_invalid;
16799 }
16800
16801 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16802
16803 if(!p_igetf(&tempfloat,f,true))
16804 {
16805 return qe_invalid;
16806 }
16807
16808 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16809
16810 if(!p_igetf(&tempfloat,f,true))
16811 {
16812 return qe_invalid;
16813 }
16814
16815 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16816
16817 if(!p_igetf(&tempfloat,f,true))
16818 {
16819 return qe_invalid;
16820 }
16821
16822 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16823 }
16824 else
16825 {
16826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.x),f,true))
16827 {
16828 return qe_invalid;
16829 }
16830
16831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.y),f,true))
16832 {
16833 return qe_invalid;
16834 }
16835
16836
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetzf(&(tempffc.vx),f,true))
16837 {
16838 return qe_invalid;
16839 }
16840
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.vy),f,true))
16842 {
16843 return qe_invalid;
16844 }
16845
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ax),f,true))
16847 {
16848 return qe_invalid;
16849 }
16850
16851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ay),f,true))
16852 {
16853 return qe_invalid;
16854 }
16855 }
16856
16857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.link),f,true))
16858 {
16859 return qe_invalid;
16860 }
16861
16862
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>7)
16863 {
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16865 {
16866 return qe_invalid;
16867 }
16868
16869 22986 tempffc.hit_width = (tempbyte&0x3F)+1;
16870 22986 tempffc.txsz = (tempbyte>>6)+1;
16871
16872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16873 {
16874 return qe_invalid;
16875 }
16876
16877 22986 tempffc.hit_height = (tempbyte&0x3F)+1;
16878 22986 tempffc.tysz = (tempbyte>>6)+1;
16879
16880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.flags),f,true))
16881 {
16882 return qe_invalid;
16883 }
16884 22986 }
16885 else
16886 {
16887 tempffc.hit_width=16;
16888 tempffc.hit_height=16;
16889 tempffc.txsz=1;
16890 tempffc.tysz=1;
16891 tempffc.flags=0;
16892 }
16893
16894 22986 tempffc.updateSolid();
16895
16896
16897
4/6
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20966 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20966 times.
22986 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16898 {
16899 tempffc.flags|=ffIGNOREHOLDUP;
16900 }
16901
16902
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>9)
16903 {
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.script),f,true))
16905 {
16906 return qe_invalid;
16907 }
16908 22986 }
16909 else
16910 {
16911 tempffc.script=0;
16912 }
16913
16914
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>10)
16915 {
16916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[0]),f,true))
16917 {
16918 return qe_invalid;
16919 }
16920
16921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[1]),f,true))
16922 {
16923 return qe_invalid;
16924 }
16925
16926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[2]),f,true))
16927 {
16928 return qe_invalid;
16929 }
16930
16931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[3]),f,true))
16932 {
16933 return qe_invalid;
16934 }
16935
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[4]),f,true))
16937 {
16938 return qe_invalid;
16939 }
16940
16941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[5]),f,true))
16942 {
16943 return qe_invalid;
16944 }
16945
16946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[6]),f,true))
16947 {
16948 return qe_invalid;
16949 }
16950
16951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[7]),f,true))
16952 {
16953 return qe_invalid;
16954 }
16955
16956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16957 {
16958 return qe_invalid;
16959 }
16960
16961 22986 tempffc.inita[0]=tempbyte*10000;
16962
16963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16964 {
16965 return qe_invalid;
16966 }
16967
16968 22986 tempffc.inita[1]=tempbyte*10000;
16969 22986 }
16970 else
16971 {
16972 tempffc.inita[0] = 10000;
16973 tempffc.inita[1] = 10000;
16974 }
16975
16976
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version <= 11)
16977 {
16978 fixffcs=true;
16979 }
16980 22986 }
16981 4896000 }
16982
16983 153000 }
16984
16985 //add in the new whistle flags
16986
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version<13)
16987 {
16988
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
16989 {
16990 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16991 12 }
16992 34744 }
16993
16994 //2.55 starts here
16995
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 19 && Header->zelda_version > 0x253 )
16996 {
16997
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17000 {
17001 return qe_invalid;
17002 }
17003 137360 }
17004
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17005 {
17006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17007 {
17008 return qe_invalid;
17009 }
17010 137360 }
17011
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17012 {
17013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17014 {
17015 return qe_invalid;
17016 }
17017 137360 }
17018
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17019 {
17020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17021 {
17022 return qe_invalid;
17023 }
17024 137360 }
17025 13736 }
17026
3/4
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 174008 times.
187744 if ( version < 19 && Header->zelda_version > 0x253 )
17027 {
17028 for ( int32_t q = 0; q < 10; q++ )
17029 {
17030 temp_mapscr->npcstrings[q] = 0;
17031 temp_mapscr->new_items[q] = 0;
17032 temp_mapscr->new_item_x[q] = 0;
17033 temp_mapscr->new_item_y[q] = 0;
17034 }
17035 }
17036
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 20 && Header->zelda_version > 0x253 )
17037 {
17038
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17039 {
17040 return qe_invalid;
17041 }
17042
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17043 {
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17045 {
17046 return qe_invalid;
17047 }
17048 109888 }
17049 13736 }
17050
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
187744 if ( version < 20 )
17051 {
17052 174008 temp_mapscr->script = 0;
17053
2/2
✓ Branch 0 taken 1392064 times.
✓ Branch 1 taken 174008 times.
1566072 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17054 174008 }
17055
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 21 && Header->zelda_version > 0x253 )
17056 {
17057
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17058 {
17059 return qe_invalid;
17060 }
17061 13736 }
17062
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 21 )
17063 {
17064 174008 temp_mapscr->preloadscript = 0;
17065 174008 }
17066 //all builds with version > 20 need this. -Z
17067
17068
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17069 {
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17071 {
17072 return qe_invalid;
17073 }
17074
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17075 {
17076 return qe_invalid;
17077 }
17078 13736 }
17079
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 22 )
17080 {
17081 174008 temp_mapscr->hidelayers = 0;
17082 174008 temp_mapscr->hidescriptlayers = 0;
17083 174008 }
17084
17085 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17086 //May be any version before 2.11. -Z
17087 /* --not the roar, the HIT SFX
17088 if ( Header->zelda_version <= 0x210 )
17089 {
17090 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17091 {
17092 temp_mapscr->bosssfx = WAV_ROAR;
17093 }
17094 }
17095 */
17096
17097 187744 return 0;
17098 187744 }
17099 202296 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17100 {
17101
2/2
✓ Branch 0 taken 187744 times.
✓ Branch 1 taken 14552 times.
202296 if(version < 23)
17102 {
17103 187744 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17104
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(ret) return ret;
17105 187744 }
17106 else
17107 {
17108
1/2
✓ Branch 0 taken 14552 times.
✗ Branch 1 not taken.
14552 if(!p_getc(&(temp_mapscr->valid),f,true))
17109 return qe_invalid;
17110
2/2
✓ Branch 0 taken 5686 times.
✓ Branch 1 taken 8866 times.
14552 if(!(temp_mapscr->valid & mVALID))
17111 8866 return 0; //Empty screen
17112 uint32_t scr_has_flags;
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5686 times.
5686 if(!p_igetl(&scr_has_flags,f,true))
17114 return qe_invalid;
17115
17116
2/2
✓ Branch 0 taken 5626 times.
✓ Branch 1 taken 60 times.
5686 if(scr_has_flags & SCRHAS_ROOMDATA)
17117 {
17118
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&(temp_mapscr->guy),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->str),f,true))
17121 return qe_invalid;
17122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!p_getc(&(temp_mapscr->room),f,true))
17123 return qe_invalid;
17124
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17125 return qe_invalid;
17126 60 }
17127
2/2
✓ Branch 0 taken 5579 times.
✓ Branch 1 taken 107 times.
5686 if(scr_has_flags & SCRHAS_ITEM)
17128 {
17129
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&(temp_mapscr->item),f,true))
17130 return qe_invalid;
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17132 return qe_invalid;
17133
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&(temp_mapscr->itemx),f,true))
17134 return qe_invalid;
17135
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_getc(&(temp_mapscr->itemy),f,true))
17136 return qe_invalid;
17137 107 }
17138
2/2
✓ Branch 0 taken 5348 times.
✓ Branch 1 taken 338 times.
5686 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17139 {
17140
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17141 return qe_invalid;
17142 338 }
17143
2/2
✓ Branch 0 taken 5461 times.
✓ Branch 1 taken 225 times.
5686 if(scr_has_flags & SCRHAS_TWARP)
17144 {
17145
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17146 {
17147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17148 return qe_invalid;
17149 900 }
17150
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17151 {
17152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17153 return qe_invalid;
17154 900 }
17155
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17156 {
17157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17158 return qe_invalid;
17159 900 }
17160
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17161 return qe_invalid;
17162 225 }
17163
2/2
✓ Branch 0 taken 5547 times.
✓ Branch 1 taken 139 times.
5686 if(scr_has_flags & SCRHAS_SWARP)
17164 {
17165
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17166 {
17167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17168 return qe_invalid;
17169 556 }
17170
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17171 {
17172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17173 return qe_invalid;
17174 556 }
17175
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17176 {
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17178 return qe_invalid;
17179 556 }
17180
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17181 return qe_invalid;
17182
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17183 return qe_invalid;
17184 139 }
17185
2/2
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 343 times.
5686 if(scr_has_flags & SCRHAS_WARPRET)
17186 {
17187
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 343 times.
1715 for(int32_t i=0; i<4; i++)
17188 {
17189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17190 return qe_invalid;
17191 1372 }
17192
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 343 times.
1715 for(int32_t i=0; i<4; i++)
17193 {
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17195 return qe_invalid;
17196 1372 }
17197
1/2
✓ Branch 0 taken 343 times.
✗ Branch 1 not taken.
343 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17198 return qe_invalid;
17199
1/2
✓ Branch 0 taken 343 times.
✗ Branch 1 not taken.
343 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17200 return qe_invalid;
17201 343 }
17202
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 4572 times.
5686 if(scr_has_flags & SCRHAS_LAYERS)
17203 {
17204
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17205 {
17206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17207 return qe_invalid;
17208 6684 }
17209
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17210 {
17211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17212 return qe_invalid;
17213 6684 }
17214
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17215 {
17216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17217 return qe_invalid;
17218 6684 }
17219
1/2
✓ Branch 0 taken 1114 times.
✗ Branch 1 not taken.
1114 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17220 return qe_invalid;
17221
1/2
✓ Branch 0 taken 1114 times.
✗ Branch 1 not taken.
1114 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17222 return qe_invalid;
17223 1114 }
17224 else
17225 {
17226
2/2
✓ Branch 0 taken 27432 times.
✓ Branch 1 taken 4572 times.
32004 for(int32_t k=0; k<6; k++)
17227 {
17228 27432 temp_mapscr->layeropacity[k] = 255;
17229 27432 }
17230 }
17231
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(scr_has_flags & SCRHAS_MAZE)
17232 {
17233 for(int32_t k=0; k<4; k++)
17234 {
17235 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17236 return qe_invalid;
17237 }
17238 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17239 return qe_invalid;
17240 }
17241
2/2
✓ Branch 0 taken 5557 times.
✓ Branch 1 taken 129 times.
5686 if(scr_has_flags & SCRHAS_D_S_U)
17242 {
17243
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17244 return qe_invalid;
17245
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t k=0; k<4; k++)
17246 {
17247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
516 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17248 return qe_invalid;
17249 516 }
17250
17251
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->stairx),f,true))
17252 return qe_invalid;
17253
17254
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->stairy),f,true))
17255 return qe_invalid;
17256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17257 return qe_invalid;
17258
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->undercset),f,true))
17259 return qe_invalid;
17260 129 }
17261
2/2
✓ Branch 0 taken 5283 times.
✓ Branch 1 taken 403 times.
5686 if(scr_has_flags & SCRHAS_FLAGS)
17262 {
17263
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags),f,true))
17264 return qe_invalid;
17265
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags2),f,true))
17266 return qe_invalid;
17267
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags3),f,true))
17268 return qe_invalid;
17269
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags4),f,true))
17270 return qe_invalid;
17271
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags5),f,true))
17272 return qe_invalid;
17273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(!p_getc(&(temp_mapscr->flags6),f,true))
17274 return qe_invalid;
17275
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags7),f,true))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags8),f,true))
17278 return qe_invalid;
17279
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags9),f,true))
17280 return qe_invalid;
17281
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags10),f,true))
17282 return qe_invalid;
17283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17284 return qe_invalid;
17285 403 }
17286
2/2
✓ Branch 0 taken 5333 times.
✓ Branch 1 taken 353 times.
5686 if(scr_has_flags & SCRHAS_ENEMY)
17287 {
17288
2/2
✓ Branch 0 taken 3530 times.
✓ Branch 1 taken 353 times.
3883 for(int32_t k=0; k<10; k++)
17289 {
17290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3530 times.
3530 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17291 return qe_invalid;
17292
1/2
✓ Branch 0 taken 3530 times.
✗ Branch 1 not taken.
3530 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17293 temp_mapscr->enemy[k] = 0;
17294 3530 }
17295
1/2
✓ Branch 0 taken 353 times.
✗ Branch 1 not taken.
353 if(!p_getc(&(temp_mapscr->pattern),f,true))
17296 return qe_invalid;
17297 353 }
17298
2/2
✓ Branch 0 taken 5653 times.
✓ Branch 1 taken 33 times.
5686 if(scr_has_flags & SCRHAS_CARRY)
17299 {
17300
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17301 return qe_invalid;
17302
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17303 return qe_invalid;
17304
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17305 return qe_invalid;
17306
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17307 return qe_invalid;
17308 33 }
17309
2/2
✓ Branch 0 taken 5655 times.
✓ Branch 1 taken 31 times.
5686 if(scr_has_flags & SCRHAS_SCRIPT)
17310 {
17311
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->script),f,true))
17312 return qe_invalid;
17313
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17314 return qe_invalid;
17315
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
279 for ( int32_t q = 0; q < 8; q++ )
17316 {
17317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17318 return qe_invalid;
17319 248 }
17320 31 }
17321
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(scr_has_flags & SCRHAS_UNUSED)
17322 {
17323 for ( int32_t q = 0; q < 10; q++ )
17324 {
17325 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17326 return qe_invalid;
17327 }
17328 for ( int32_t q = 0; q < 10; q++ )
17329 {
17330 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17331 return qe_invalid;
17332 }
17333 for ( int32_t q = 0; q < 10; q++ )
17334 {
17335 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17336 return qe_invalid;
17337 }
17338 for ( int32_t q = 0; q < 10; q++ )
17339 {
17340 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17341 return qe_invalid;
17342 }
17343 }
17344
2/2
✓ Branch 0 taken 5293 times.
✓ Branch 1 taken 393 times.
5686 if(scr_has_flags & SCRHAS_SECRETS)
17345 {
17346
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17347 {
17348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17349 return qe_invalid;
17350 50304 }
17351
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17352 {
17353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17354 return qe_invalid;
17355 50304 }
17356
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17357 {
17358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17359 return qe_invalid;
17360 50304 }
17361 393 }
17362
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2741 times.
5686 if(scr_has_flags & SCRHAS_COMBOFLAG)
17363 {
17364
2/2
✓ Branch 0 taken 482416 times.
✓ Branch 1 taken 2741 times.
485157 for(int32_t k=0; k<176; ++k)
17365 {
17366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482416 times.
482416 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17367 return qe_invalid;
17368 482416 }
17369
2/2
✓ Branch 0 taken 482416 times.
✓ Branch 1 taken 2741 times.
485157 for(int32_t k=0; k<176; ++k)
17370 {
17371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482416 times.
482416 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17372 return qe_invalid;
17373 482416 }
17374
2/2
✓ Branch 0 taken 482416 times.
✓ Branch 1 taken 2741 times.
485157 for(int32_t k=0; k<176; ++k)
17375 {
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482416 times.
482416 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17377 return qe_invalid;
17378 482416 }
17379 2741 }
17380
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(scr_has_flags & SCRHAS_MISC)
17381 {
17382
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_igetw(&(temp_mapscr->color),f,true))
17383 return qe_invalid;
17384
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17385 return qe_invalid;
17386
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17387 return qe_invalid;
17388
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17389 return qe_invalid;
17390
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17391 return qe_invalid;
17392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5686 times.
5686 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17393 return qe_invalid;
17394
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17395 return qe_invalid;
17396
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17397 return qe_invalid;
17398
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17399 return qe_invalid;
17400 5686 }
17401 else
17402 {
17403 temp_mapscr->screen_midi = -1;
17404 temp_mapscr->csensitive = 1;
17405 }
17406 //FFC
17407 5686 bool old_ff = version < 25;
17408 5686 dword bits = 0;
17409 5686 word numffc = 32;
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5686 times.
5686 if(old_ff)
17411 {
17412 if(!p_igetl(&bits,f,true))
17413 return qe_invalid;
17414 }
17415 else
17416 {
17417
1/2
✓ Branch 0 taken 5686 times.
✗ Branch 1 not taken.
5686 if(!p_igetw(&numffc,f,true))
17418 return qe_invalid;
17419 }
17420 byte tempbyte;
17421 word tempw;
17422
4/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 5660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
5686 static ffcdata nil_ffc;
17423 5686 temp_mapscr->ffcCountMarkDirty();
17424
2/2
✓ Branch 0 taken 5686 times.
✓ Branch 1 taken 7761 times.
13447 for(word m = 0; m < numffc; ++m)
17425 {
17426
1/2
✓ Branch 0 taken 7761 times.
✗ Branch 1 not taken.
7761 ffcdata& tempffc = (m < MAXFFCS)
17427 7761 ? temp_mapscr->ffcs[m]
17428 : nil_ffc; //sanity
17429 7761 tempffc.clear();
17430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7761 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7761 if(old_ff && !(bits & (1<<m))) continue;
17431
17432
1/2
✓ Branch 0 taken 7761 times.
✗ Branch 1 not taken.
7761 if(!p_igetw(&tempw,f,true))
17433 return qe_invalid;
17434
3/4
✓ Branch 0 taken 7761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 6458 times.
7761 if(!old_ff && !tempw) //empty ffc, nothing more to load
17435 6458 continue;
17436 1303 tempffc.setData(tempw);
17437
17438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_getc(&(tempffc.cset),f,true))
17439 return qe_invalid;
17440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetw(&(tempffc.delay),f,true))
17441 return qe_invalid;
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetzf(&(tempffc.x),f,true))
17443 return qe_invalid;
17444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetzf(&(tempffc.y),f,true))
17445 return qe_invalid;
17446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetzf(&(tempffc.vx),f,true))
17447 return qe_invalid;
17448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetzf(&(tempffc.vy),f,true))
17449 return qe_invalid;
17450
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_igetzf(&(tempffc.ax),f,true))
17451 return qe_invalid;
17452
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_igetzf(&(tempffc.ay),f,true))
17453 return qe_invalid;
17454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_getc(&(tempffc.link),f,true))
17455 return qe_invalid;
17456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(version < 24)
17457 {
17458 if(!p_getc(&tempbyte,f,true))
17459 return qe_invalid;
17460 tempffc.hit_width = (tempbyte&0x3F)+1;
17461 tempffc.txsz = (tempbyte>>6)+1;
17462 if(!p_getc(&tempbyte,f,true))
17463 return qe_invalid;
17464 tempffc.hit_height = (tempbyte&0x3F)+1;
17465 tempffc.tysz = (tempbyte>>6)+1;
17466 }
17467 else
17468 {
17469
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_igetl(&(tempffc.hit_width),f,true))
17470 return qe_invalid;
17471
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_igetl(&(tempffc.hit_height),f,true))
17472 return qe_invalid;
17473
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_getc(&(tempffc.txsz),f,true))
17474 return qe_invalid;
17475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_getc(&(tempffc.tysz),f,true))
17476 return qe_invalid;
17477 }
17478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetl(&(tempffc.flags),f,true))
17479 return qe_invalid;
17480 1303 tempffc.updateSolid();
17481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_igetw(&(tempffc.script),f,true))
17482 return qe_invalid;
17483
2/2
✓ Branch 0 taken 10424 times.
✓ Branch 1 taken 1303 times.
11727 for(auto q = 0; q < 8; ++q)
17484 {
17485
1/2
✓ Branch 0 taken 10424 times.
✗ Branch 1 not taken.
10424 if(!p_igetl(&(tempffc.initd[q]),f,true))
17486 return qe_invalid;
17487 10424 }
17488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(!p_getc(&(tempbyte),f,true))
17489 return qe_invalid;
17490 1303 tempffc.inita[0]=tempbyte*10000;
17491
17492
1/2
✓ Branch 0 taken 1303 times.
✗ Branch 1 not taken.
1303 if(!p_getc(&(tempbyte),f,true))
17493 return qe_invalid;
17494 1303 tempffc.inita[1]=tempbyte*10000;
17495 1303 }
17496
2/2
✓ Branch 0 taken 720047 times.
✓ Branch 1 taken 5686 times.
725733 for(word m = numffc; m < MAXFFCS; ++m)
17497 {
17498 720047 temp_mapscr->ffcs[m].clear();
17499 720047 }
17500 //END FFC
17501 }
17502 193430 return 0;
17503 202296 }
17504
17505
17506 114 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17507 {
17508 114 int32_t scr=0;
17509
17510 114 word version=0;
17511 dword dummy;
17512 int32_t screens_to_read;
17513
17514 114 mapscr temp_mapscr;
17515 zcmap temp_map;
17516 word temp_map_count;
17517 dword section_size;
17518
17519
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17520 {
17521 4 screens_to_read=MAPSCRS192b136;
17522 4 }
17523 else
17524 {
17525 110 screens_to_read=MAPSCRS;
17526 }
17527
17528
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version > 0x192)
17529 {
17530 //section version info
17531
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&version,f,true))
17532 {
17533 return qe_invalid;
17534 }
17535
17536 110 FFCore.quest_format[vMaps] = version;
17537
17538 //al_trace("Maps version %d\n", version);
17539
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
17540 {
17541 return qe_invalid;
17542 }
17543
17544 //section size
17545
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&section_size,f,true))
17546 {
17547 return qe_invalid;
17548 }
17549
17550 //finally... section data
17551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_igetw(&temp_map_count,f,true))
17552 {
17553 return 5;
17554 }
17555 110 }
17556 else
17557 {
17558 4 temp_map_count=map_count;
17559 }
17560
17561
17562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
17563 {
17564 114 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17565 114 TheMaps.resize(_mapsSize);
17566
17567
2/2
✓ Branch 0 taken 203456 times.
✓ Branch 1 taken 114 times.
203570 for(int32_t i(0); i<_mapsSize; i++)
17568 203456 TheMaps[i].zero_memory();
17569
17570 114 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17571 114 }
17572
17573 114 temp_mapscr.zero_memory();
17574
17575 114 memset(&temp_map, 0, sizeof(zcmap));
17576 114 temp_map.scrResWidth = 256;
17577 114 temp_map.scrResHeight = 224;
17578 114 temp_map.tileWidth = 16;
17579 114 temp_map.tileHeight = 11;
17580 114 temp_map.viewWidth = 256;
17581 114 temp_map.viewHeight = 176;
17582 114 temp_map.viewX = 0;
17583 114 temp_map.viewY = 64;
17584 114 temp_map.subaWidth = 256;
17585 114 temp_map.subaHeight = 168;
17586 114 temp_map.subaTrans = false;
17587 114 temp_map.subpWidth = 256;
17588 114 temp_map.subpHeight = 56;
17589 114 temp_map.subpTrans = false;
17590
4/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1496 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 114 times.
1610 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17591 {
17592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1496 times.
1496 if(keepdata==true) //!TODO Trim fully
17593 {
17594 1496 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17595 1496 }
17596 1496 byte valid=1;
17597
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 114 times.
1496 if(version > 22)
17598 {
17599
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&valid,f,true))
17600 return qe_invalid;
17601 114 }
17602
2/2
✓ Branch 0 taken 203248 times.
✓ Branch 1 taken 1496 times.
204744 for(int32_t j=0; j<screens_to_read; j++)
17603 {
17604 203248 scr=i*MAPSCRS+j;
17605 203248 clear_screen(&temp_mapscr);
17606
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 202296 times.
203248 if(valid)
17607 202296 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17608
17609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203248 times.
203248 if(keepdata==true)
17610 {
17611 203248 TheMaps[scr] = temp_mapscr;
17612 203248 }
17613 203248 }
17614
17615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1496 times.
1496 if(keepdata==true)
17616 {
17617
3/6
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1496 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17618 {
17619 52 int32_t index = (i*MAPSCRS+132);
17620
17621 52 TheMaps[index]=TheMaps[index-1];
17622
17623 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17624 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17625 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17626
17627
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17628 {
17629 156 scr=i*MAPSCRS+j;
17630
17631 156 TheMaps[scr].zero_memory();
17632 156 TheMaps[scr].valid = mVERSION;
17633 156 TheMaps[scr].screen_midi = -1;
17634 156 TheMaps[scr].csensitive = 1;
17635 156 }
17636 52 }
17637
17638
3/6
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1496 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17639 {
17640
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17641 {
17642 7072 scr=i*MAPSCRS+j;
17643 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17644
17645
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17646 {
17647 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17648 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17649 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17650 905216 }
17651 7072 }
17652 52 }
17653 1496 }
17654 1496 }
17655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
17656 {
17657 114 map_count = temp_map_count;
17658 114 }
17659 114 clear_screen(&temp_mapscr);
17660 114 return 0;
17661 114 }
17662
17663
17664 701689 void update_combo(newcombo& cmb, word section_version)
17665 {
17666
2/2
✓ Branch 0 taken 97356 times.
✓ Branch 1 taken 604333 times.
701689 if(section_version < 40)
17667 {
17668
3/3
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 12036 times.
✓ Branch 2 taken 590935 times.
604333 switch(cmb.type)
17669 {
17670 case cWATER: case cSHALLOWWATER:
17671 12036 cmb.attribytes[6] = iwRipples;
17672 12036 break;
17673 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17674 1362 cmb.attribytes[6] = iwTallGrass;
17675 1362 break;
17676 }
17677 604333 }
17678 701689 }
17679 87 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17680 {
17681 87 reset_combo_animations();
17682 87 reset_combo_animations2();
17683
17684 87 init_combo_classes();
17685
17686 // combos
17687 87 word combos_used=0;
17688 int32_t dummy;
17689 byte padding;
17690 87 newcombo temp_combo;
17691 //word section_cversion=0;
17692
17693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata==true)
17694 {
17695
2/2
✓ Branch 0 taken 5679360 times.
✓ Branch 1 taken 87 times.
5679447 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17696
1/2
✓ Branch 0 taken 5679360 times.
✗ Branch 1 not taken.
5679360 combobuf[q].clear();
17697 87 }
17698
17699 // if(version > 0x192)
17700 // {
17701 // //section version info
17702 // if(!p_igetw(&section_version,f,true))
17703 // {
17704 // return qe_invalid;
17705 // }
17706
17707 // FFCore.quest_format[vCombos] = section_version;
17708
17709 // //al_trace("Combos version %d\n", section_version);
17710 // if(!p_igetw(&section_cversion,f,true))
17711 // {
17712 // return qe_invalid;
17713 // }
17714
17715 // //section size
17716 // if(!p_igetl(&dummy,f,true))
17717 // {
17718 // return qe_invalid;
17719 // }
17720 // }
17721
17722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(version < 0x174)
17723 {
17724 combos_used=1024;
17725 }
17726
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
87 else if(version < 0x191)
17727 {
17728 4 combos_used=2048;
17729 4 }
17730 else
17731 {
17732
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&combos_used,f,true))
17733 {
17734 return qe_invalid;
17735 }
17736 }
17737
17738 //finally... section data
17739
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 516329 times.
516416 for(int32_t i=0; i<combos_used; i++)
17740 {
17741
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 temp_combo.clear();
17742
17743
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if ( section_version >= 11 )
17744 {
17745
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17746 {
17747 return qe_invalid;
17748 }
17749 68884 }
17750 else
17751 {
17752
2/4
✓ Branch 0 taken 447445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447445 times.
✗ Branch 3 not taken.
447445 if(!p_igetw(&temp_combo.tile,f,true))
17753 {
17754 return qe_invalid;
17755 }
17756 }
17757 516329 temp_combo.o_tile = temp_combo.tile;
17758
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.flip,f,true))
17759 {
17760 return qe_invalid;
17761 }
17762
17763
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.walk,f,true))
17764 {
17765 return qe_invalid;
17766 }
17767
17768
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.type,f,true))
17769 {
17770 return qe_invalid;
17771 }
17772
17773
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.csets,f,true))
17774 {
17775 return qe_invalid;
17776 }
17777
17778
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 508137 times.
516329 if(version < 0x193)
17779 {
17780
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17781 return qe_invalid;
17782
17783
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17784 return qe_invalid;
17785
17786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17787 {
17788
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17789 {
17790 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17791 {
17792 if(!p_getc(&padding,f,true))
17793 return qe_invalid;
17794 }
17795 }
17796 8192 }
17797 8192 }
17798
2/2
✓ Branch 0 taken 508137 times.
✓ Branch 1 taken 8192 times.
516329 if(version >= 0x192)
17799 {
17800
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.frames,f,true))
17801 return qe_invalid;
17802
17803
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.speed,f,true))
17804 return qe_invalid;
17805
17806
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_igetw(&temp_combo.nextcombo,f,true))
17807 return qe_invalid;
17808
17809
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.nextcset,f,true))
17810 return qe_invalid;
17811
17812 //Base flag
17813
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=3)
17814
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.flag,f,true))
17815 return qe_invalid;
17816
17817
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=4)
17818 {
17819
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanim,f,true))
17820 return qe_invalid;
17821
17822
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_igetw(&temp_combo.nexttimer,f,true))
17823 return qe_invalid;
17824 399023 }
17825
17826
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=5)
17827
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanimy,f,true))
17828 return qe_invalid;
17829
17830
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=6)
17831 {
17832
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.animflags,f,true))
17833 return qe_invalid;
17834
17835
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(section_version == 6)
17836 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17837 399023 }
17838
17839
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=8) //combo Attributes[4] and userflags.
17840 {
17841
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17842
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17843 return qe_invalid;
17844
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17845 return qe_invalid;
17846
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17847
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17848 return qe_invalid;
17849 68884 }
17850
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=10) //combo trigger flags
17851 {
17852
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17853
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17854 return qe_invalid;
17855 68884 }
17856
1/2
✓ Branch 0 taken 439253 times.
✗ Branch 1 not taken.
439253 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17857 {
17858 for ( int32_t q = 0; q < 2; q++ )
17859 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17860 return qe_invalid;
17861 }
17862
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 9)
17863
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17864 return qe_invalid;
17865
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 22)
17866
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17867 return qe_invalid;
17868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 24)
17869 {
17870 if(!p_getc(&temp_combo.triggeritem,f,true))
17871 return qe_invalid;
17872 if(!p_getc(&temp_combo.trigtimer,f,true))
17873 return qe_invalid;
17874 }
17875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 25)
17876 if(!p_getc(&temp_combo.trigsfx,f,true))
17877 return qe_invalid;
17878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 27)
17879 if(!p_igetl(&temp_combo.trigchange,f,true))
17880 return qe_invalid;
17881
17882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 29)
17883 {
17884 if(!p_igetw(&temp_combo.trigprox,f,true))
17885 return qe_invalid;
17886 if(!p_getc(&temp_combo.trigctr,f,true))
17887 return qe_invalid;
17888 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17889 return qe_invalid;
17890 }
17891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 30)
17892 if(!p_getc(&temp_combo.triglbeam,f,true))
17893 return qe_invalid;
17894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 31)
17895 {
17896 if(!p_getc(&temp_combo.trigcschange,f,true))
17897 return qe_invalid;
17898 if(!p_igetw(&temp_combo.spawnitem,f,true))
17899 return qe_invalid;
17900 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17901 return qe_invalid;
17902 if(!p_getc(&temp_combo.exstate,f,true))
17903 return qe_invalid;
17904 if(!p_igetl(&temp_combo.spawnip,f,true))
17905 return qe_invalid;
17906 if(!p_getc(&temp_combo.trigcopycat,f,true))
17907 return qe_invalid;
17908 }
17909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 32)
17910 if(!p_getc(&temp_combo.trigcooldown,f,true))
17911 return qe_invalid;
17912
17913
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=12) //combo label
17914 {
17915 char label[12];
17916 68884 label[11] = '\0';
17917
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17918
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f,true))
17919 return qe_invalid;
17920
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17921 68884 }
17922
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=13) //attribytes[4]
17923
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17924
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17925 68884 return qe_invalid;
17926 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17927 * This fixes a poor implementation of a ->next flag bug thing.
17928 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17929 * there was a version bump a few weeks before a change that broke stuff.
17930 */
17931
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
508137 if (section_version >= 13 && section_version < 21)
17932 {
17933 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17934 }
17935 //combo scripts
17936
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=14)
17937 {
17938
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17939 return qe_invalid;
17940
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17941
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17942 return qe_invalid;
17943 68884 }
17944 //al_trace("Read combo script data\n");
17945
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=15)
17946 {
17947
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17948
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17949
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17950
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17951 68884 }
17952
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=17) //attribytes[4]
17953 {
17954
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17955
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17956 return qe_invalid;
17957
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17958
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17959 return qe_invalid;
17960 68884 }
17961
17962
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(version < 0x193)
17963 for(int32_t q=0; q<11; q++)
17964 if(!p_getc(&dummy,f,true))
17965 return qe_invalid;
17966 508137 }
17967
17968 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17969
3/6
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399023 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516329 if((version < 0x211)||((version == 0x211)&&(build<7)))
17970 {
17971
3/4
✓ Branch 0 taken 117306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109114 times.
✓ Branch 3 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17972 {
17973
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17974 {
17975 case 130:
17976 temp_combo.tile = 132;
17977 break;
17978
17979 case 131:
17980 temp_combo.tile = 133;
17981 break;
17982
17983 case 132:
17984 temp_combo.tile = 130;
17985 break;
17986
17987 case 133:
17988 temp_combo.tile = 131;
17989 break;
17990 }
17991 8192 }
17992 117306 }
17993
17994
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 15)
17995 447445 temp_combo.o_tile = temp_combo.tile;
17996
17997
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version<18) //upper bits for .walk
17998 447445 temp_combo.walk |= 0xF0;
17999
18000
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 19)
18001
2/2
✓ Branch 0 taken 1789780 times.
✓ Branch 1 taken 447445 times.
2237225 for(int32_t q = 0; q < 4; ++q)
18002 2237225 temp_combo.attributes[q] *= 10000L;
18003
18004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 23)
18005 {
18006
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 515945 times.
516329 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
18007 {
18008 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18009 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18010 case cTRIGGERGENERIC: case cCSWITCH:
18011 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
18012 384 }
18013 516329 }
18014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 25)
18015 {
18016
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 513681 times.
516329 switch(temp_combo.type)
18017 {
18018 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
2648 if(!(temp_combo.usrflags & cflag3))
18020 2648 temp_combo.attribytes[3] = WAV_DOOR;
18021 2648 temp_combo.usrflags &= ~cflag3;
18022 2648 break;
18023 }
18024 516329 }
18025
18026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 26)
18027
2/2
✓ Branch 0 taken 515799 times.
✓ Branch 1 taken 530 times.
516859 if(temp_combo.type == cARMOS)
18028
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if(temp_combo.usrflags & cflag1)
18029 temp_combo.usrflags |= cflag3;
18030
18031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 27)
18032 {
18033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
18034 temp_combo.trigchange = 1;
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
18036 temp_combo.trigchange = -1;
18037 516329 else temp_combo.trigchange = 0;
18038 516329 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
18039 516329 }
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 28)
18041 {
18042
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 514920 times.
516329 switch(temp_combo.type)
18043 {
18044 case cLOCKBLOCK: case cLOCKEDCHEST:
18045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1409 times.
1409 if(temp_combo.usrflags & cflag7)
18046 temp_combo.usrflags |= cflag8;
18047 1409 else temp_combo.usrflags &= ~cflag8;
18048 1409 temp_combo.usrflags &= ~cflag7;
18049 1409 break;
18050 }
18051
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 516260 times.
516329 switch(temp_combo.type)
18052 {
18053 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18054 69 temp_combo.attrishorts[2] = -1;
18055 69 temp_combo.usrflags |= cflag7;
18056 69 break;
18057 }
18058 516329 }
18059
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 20)
18060 {
18061 447445 temp_combo.genflags = 0;
18062
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 429922 times.
447445 switch(temp_combo.type)
18063 {
18064 case cPUSH_WAIT: case cPUSH_HEAVY:
18065 case cPUSH_HW: case cL_STATUE:
18066 case cR_STATUE: case cPUSH_HEAVY2:
18067 case cPUSH_HW2: case cPOUND:
18068 case cC_STATUE: case cMIRROR:
18069 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18070 case cMAGICPRISM: case cMAGICPRISM4:
18071 case cMAGICSPONGE: case cEYEBALL_A:
18072 case cEYEBALL_B: case cEYEBALL_4:
18073 case cBUSH: case cFLOWERS:
18074 case cLOCKBLOCK: case cLOCKBLOCK2:
18075 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18076 case cCHEST: case cCHEST2:
18077 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18078 case cBOSSCHEST: case cBOSSCHEST2:
18079 case cBUSHNEXT: case cBUSHTOUCHY:
18080 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18081 case cSIGNPOST: case cCSWITCHBLOCK:
18082 case cTORCH: case cTRIGGERGENERIC:
18083
1/2
✓ Branch 0 taken 17523 times.
✗ Branch 1 not taken.
17523 if(temp_combo.usrflags & cflag16)
18084 {
18085 temp_combo.genflags |= cflag1;
18086 temp_combo.usrflags &= ~cflag16;
18087 }
18088 17523 break;
18089 }
18090 447445 }
18091
18092 516329 update_combo(temp_combo, section_version);
18093
18094
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(keepdata==true && i>=start_combo)
18095 {
18096
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 combobuf[i] = temp_combo;
18097 516329 }
18098 516329 }
18099
18100
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(keepdata==true)
18101 {
18102
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18103 {
18104
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18105 {
18106
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18107 {
18108 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18109 }
18110 261120 }
18111 4 }
18112
18113 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18114
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
87 if(version == 0x210 && !is_zquest())
18115 {
18116
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18117
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18118 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18119 5 }
18120
18121
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 9 times.
87 if(section_version<7)
18122 {
18123
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18124 {
18125
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18126 {
18127 case cSLASH:
18128 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18129 61 break;
18130
18131 case cSLASHITEM:
18132 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18133 62 break;
18134
18135 case cBUSH:
18136 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18137 28 break;
18138
18139 case cFLOWERS:
18140 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18141 10 break;
18142
18143 case cTALLGRASS:
18144 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18145 10 break;
18146
18147 case cSLASHNEXT:
18148 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18149 break;
18150
18151 case cSLASHNEXTITEM:
18152 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18153 break;
18154
18155 case cBUSHNEXT:
18156 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18157 break;
18158 }
18159 587520 }
18160 9 }
18161
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 85 times.
87 if (section_version < 16)
18162 {
18163
2/2
✓ Branch 0 taken 5548800 times.
✓ Branch 1 taken 85 times.
5548885 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18164 {
18165
2/2
✓ Branch 0 taken 5543143 times.
✓ Branch 1 taken 5657 times.
5548800 if (combobuf[tmpcounter].type == cWATER)
18166 {
18167 5657 combobuf[tmpcounter].attributes[0] = 40000L;
18168 5657 }
18169 5548800 }
18170 85 }
18171
3/4
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 1 times.
87 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18172 {
18173 1 combobuf[0].walk = 0xF0;
18174 1 combobuf[0].type = 0;
18175 1 combobuf[0].flag = 0;
18176 1 }
18177 87 }
18178
18179 //Now for the new combo alias reset
18180
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
87 if(section_version<2 && keepdata)
18181 {
18182
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18183 {
18184 73728 combo_aliases[j].width = 0;
18185 73728 combo_aliases[j].height = 0;
18186 73728 combo_aliases[j].layermask = 0;
18187
18188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18189 {
18190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].combos;
18191 73728 }
18192
18193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18194 {
18195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].csets;
18196 73728 }
18197
18198
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].combos = new word[1];
18199
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].csets = new byte[1];
18200 73728 combo_aliases[j].combos[0] = 0;
18201 73728 combo_aliases[j].csets[0] = 0;
18202 73728 }
18203 9 }
18204
18205
18206
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations();
18207
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations2();
18208 87 return 0;
18209 87 }
18210 185360 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18211 {
18212 byte combo_has_flags;
18213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185360 times.
185360 if(!p_getc(&combo_has_flags,f,true))
18214 return qe_invalid;
18215
18216 185360 temp_combo.clear();
18217
2/2
✓ Branch 0 taken 120371 times.
✓ Branch 1 taken 64989 times.
185360 if(combo_has_flags)
18218 {
18219
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 64986 times.
64989 if(combo_has_flags&CHAS_BASIC)
18220 {
18221
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_igetl(&temp_combo.tile,f,true))
18222 {
18223 return qe_invalid;
18224 }
18225 64986 temp_combo.o_tile = temp_combo.tile;
18226
18227
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.flip,f,true))
18228 {
18229 return qe_invalid;
18230 }
18231
18232
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.walk,f,true))
18233 {
18234 return qe_invalid;
18235 }
18236
18237
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.type,f,true))
18238 {
18239 return qe_invalid;
18240 }
18241
18242
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.flag,f,true))
18243 {
18244 return qe_invalid;
18245 }
18246
18247
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.csets,f,true))
18248 {
18249 return qe_invalid;
18250 }
18251 64986 }
18252
2/2
✓ Branch 0 taken 64966 times.
✓ Branch 1 taken 23 times.
64989 if(combo_has_flags&CHAS_SCRIPT)
18253 {
18254
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18255 {
18256 8 p_getcstr(&temp_combo.label, f, true);
18257 8 }
18258 else
18259 {
18260 char label[12];
18261 15 label[11] = '\0';
18262
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18263 {
18264
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f,true))
18265 {
18266 return qe_invalid;
18267 }
18268 165 }
18269 15 temp_combo.label = label;
18270 }
18271
18272
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18273
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18274 {
18275
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f,true))
18276 {
18277 return qe_invalid;
18278 }
18279 46 }
18280 23 }
18281
2/2
✓ Branch 0 taken 46482 times.
✓ Branch 1 taken 18507 times.
64989 if(combo_has_flags&CHAS_ANIM)
18282 {
18283
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.frames,f,true))
18284 {
18285 return qe_invalid;
18286 }
18287
18288
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.speed,f,true))
18289 {
18290 return qe_invalid;
18291 }
18292
18293
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_igetw(&temp_combo.nextcombo,f,true))
18294 {
18295 return qe_invalid;
18296 }
18297
18298
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.nextcset,f,true))
18299 {
18300 return qe_invalid;
18301 }
18302
18303
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.skipanim,f,true))
18304 {
18305 return qe_invalid;
18306 }
18307
18308
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.skipanimy,f,true))
18309 {
18310 return qe_invalid;
18311 }
18312
18313
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.animflags,f,true))
18314 {
18315 return qe_invalid;
18316 }
18317 18507 }
18318
2/2
✓ Branch 0 taken 57447 times.
✓ Branch 1 taken 7542 times.
64989 if(combo_has_flags&CHAS_ATTRIB)
18319 {
18320
2/2
✓ Branch 0 taken 30168 times.
✓ Branch 1 taken 7542 times.
37710 for ( int32_t q = 0; q < 4; q++ )
18321 {
18322
1/2
✓ Branch 0 taken 30168 times.
✗ Branch 1 not taken.
30168 if(!p_igetl(&temp_combo.attributes[q],f,true))
18323 {
18324 return qe_invalid;
18325 }
18326 30168 }
18327
2/2
✓ Branch 0 taken 60336 times.
✓ Branch 1 taken 7542 times.
67878 for ( int32_t q = 0; q < 8; q++ )
18328 {
18329
1/2
✓ Branch 0 taken 60336 times.
✗ Branch 1 not taken.
60336 if(!p_getc(&temp_combo.attribytes[q],f,true))
18330 {
18331 return qe_invalid;
18332 }
18333 60336 }
18334
2/2
✓ Branch 0 taken 60336 times.
✓ Branch 1 taken 7542 times.
67878 for ( int32_t q = 0; q < 8; q++ )
18335 {
18336
1/2
✓ Branch 0 taken 60336 times.
✗ Branch 1 not taken.
60336 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18337 {
18338 return qe_invalid;
18339 }
18340 60336 }
18341 7542 }
18342
2/2
✓ Branch 0 taken 63265 times.
✓ Branch 1 taken 1724 times.
64989 if(combo_has_flags&CHAS_FLAG)
18343 {
18344
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
1724 if(!p_igetl(&temp_combo.usrflags,f,true))
18345 {
18346 return qe_invalid;
18347 }
18348
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
1724 if(!p_igetw(&temp_combo.genflags,f,true))
18349 {
18350 return qe_invalid;
18351 }
18352 1724 }
18353
2/2
✓ Branch 0 taken 64469 times.
✓ Branch 1 taken 520 times.
64989 if(combo_has_flags&CHAS_TRIG)
18354 {
18355 520 int numtrigs = s_version < 36 ? 3 : 6;
18356
2/2
✓ Branch 0 taken 2664 times.
✓ Branch 1 taken 520 times.
3184 for ( int32_t q = 0; q < numtrigs; q++ )
18357 {
18358
1/2
✓ Branch 0 taken 2664 times.
✗ Branch 1 not taken.
2664 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18359 {
18360 return qe_invalid;
18361 }
18362 2664 }
18363
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18364 {
18365 return qe_invalid;
18366 }
18367
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triggerbtn,f,true))
18368 {
18369 return qe_invalid;
18370 }
18371
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triggeritem,f,true))
18372 {
18373 return qe_invalid;
18374 }
18375
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigtimer,f,true))
18376 {
18377 return qe_invalid;
18378 }
18379
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigsfx,f,true))
18380 {
18381 return qe_invalid;
18382 }
18383
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.trigchange,f,true))
18384 {
18385 return qe_invalid;
18386 }
18387
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.trigprox,f,true))
18388 {
18389 return qe_invalid;
18390 }
18391
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigctr,f,true))
18392 {
18393 return qe_invalid;
18394 }
18395
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18396 {
18397 return qe_invalid;
18398 }
18399
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triglbeam,f,true))
18400 {
18401 return qe_invalid;
18402 }
18403
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcschange,f,true))
18404 {
18405 return qe_invalid;
18406 }
18407
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.spawnitem,f,true))
18408 {
18409 return qe_invalid;
18410 }
18411
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18412 {
18413 return qe_invalid;
18414 }
18415
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.exstate,f,true))
18416 {
18417 return qe_invalid;
18418 }
18419
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.spawnip,f,true))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcopycat,f,true))
18424 {
18425 return qe_invalid;
18426 }
18427
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcooldown,f,true))
18428 {
18429 return qe_invalid;
18430 }
18431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520 times.
520 if(s_version >= 35)
18432 {
18433
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18434 {
18435 return qe_invalid;
18436 }
18437
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.prompt_cs,f,true))
18438 {
18439 return qe_invalid;
18440 }
18441
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_x,f,true))
18442 {
18443 return qe_invalid;
18444 }
18445
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_y,f,true))
18446 {
18447 return qe_invalid;
18448 }
18449 520 }
18450
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 368 times.
520 if(s_version >= 36)
18451 {
18452
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
368 if(!p_getc(&temp_combo.trig_lstate,f,true))
18453 {
18454 return qe_invalid;
18455 }
18456
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
368 if(!p_getc(&temp_combo.trig_gstate,f,true))
18457 {
18458 return qe_invalid;
18459 }
18460
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
368 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18461 {
18462 return qe_invalid;
18463 }
18464 368 }
18465
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 368 times.
520 if(s_version >= 37)
18466 {
18467
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
368 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18468 {
18469 return qe_invalid;
18470 }
18471 368 }
18472
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 294 times.
520 if(s_version >= 38)
18473 {
18474
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if(!p_getc(&temp_combo.trig_group,f,true))
18475 {
18476 return qe_invalid;
18477 }
18478
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18479 {
18480 return qe_invalid;
18481 }
18482 294 }
18483 520 }
18484
2/2
✓ Branch 0 taken 64874 times.
✓ Branch 1 taken 115 times.
64989 if(combo_has_flags&CHAS_LIFT)
18485 {
18486
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftcmb,f,true))
18487 return qe_invalid;
18488
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftcs,f,true))
18489 return qe_invalid;
18490
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18491 return qe_invalid;
18492
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftundercs,f,true))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftdmg,f,true))
18495 return qe_invalid;
18496
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftlvl,f,true))
18497 return qe_invalid;
18498
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftitm,f,true))
18499 return qe_invalid;
18500
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftflags,f,true))
18501 return qe_invalid;
18502
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftgfx,f,true))
18503 return qe_invalid;
18504
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftsprite,f,true))
18505 return qe_invalid;
18506
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftsfx,f,true))
18507 return qe_invalid;
18508
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18509 return qe_invalid;
18510
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18511 return qe_invalid;
18512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version >= 34)
18513 {
18514
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.lifthei,f,true))
18515 return qe_invalid;
18516
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.lifttime,f,true))
18517 return qe_invalid;
18518 115 }
18519
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 104 times.
115 if(s_version >= 39)
18520 {
18521
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_combo.lift_parent_item,f,true))
18522 return qe_invalid;
18523 104 }
18524 115 }
18525
2/2
✓ Branch 0 taken 64973 times.
✓ Branch 1 taken 16 times.
64989 if(combo_has_flags&CHAS_GENERAL)
18526 {
18527
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_mult,f,true))
18528 return qe_invalid;
18529
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_div,f,true))
18530 return qe_invalid;
18531
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetzf(&temp_combo.speed_add,f,true))
18532 return qe_invalid;
18533 16 }
18534 64989 }
18535 185360 update_combo(temp_combo, s_version);
18536 185360 return 0;
18537 185360 }
18538 114 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18539 {
18540 114 word section_version=0;
18541 114 word section_cversion=0;
18542 114 word combos_used=0;
18543 int32_t dummy;
18544 byte padding;
18545 114 newcombo temp_combo;
18546
18547
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 reset_combo_animations();
18548
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 reset_combo_animations2();
18549
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 init_combo_classes();
18550
18551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true) //reset combos
18552 {
18553
2/2
✓ Branch 0 taken 7441920 times.
✓ Branch 1 taken 114 times.
7442034 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18554
1/2
✓ Branch 0 taken 7441920 times.
✗ Branch 1 not taken.
7441920 combobuf[q].clear();
18555 114 }
18556
18557
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(version > 0x192) //Version info
18558 {
18559
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&section_version,f,true))
18560 {
18561 return qe_invalid;
18562 }
18563 110 FFCore.quest_format[vCombos] = section_version;
18564
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&section_cversion,f,true))
18565 {
18566 return qe_invalid;
18567 }
18568
18569 //section size
18570
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy,f,true))
18571 {
18572 return qe_invalid;
18573 }
18574 110 }
18575
18576
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(section_version > 32) //Cleanup time!
18577 {
18578
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
27 if(!p_igetw(&combos_used,f,true))
18579 {
18580 return qe_invalid;
18581 }
18582
2/2
✓ Branch 0 taken 185360 times.
✓ Branch 1 taken 27 times.
185387 for(int32_t i=0; i<combos_used; i++)
18583 {
18584
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 auto ret = readcombo_loop(f,section_version,temp_combo);
18585
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 if(ret) return ret;
18586
2/4
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185360 times.
✗ Branch 3 not taken.
185360 if(keepdata==true && i>=start_combo)
18587
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 combobuf[i] = temp_combo;
18588 185360 }
18589 27 }
18590 else //Call the old function for all old versions
18591 {
18592
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(ret) return ret; //error, end read
18594 }
18595
18596
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(keepdata==true)
18597 {
18598
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 88 times.
114 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18599 {
18600 26 combobuf[0].walk = 0xF0;
18601 26 combobuf[0].type = 0;
18602 26 combobuf[0].flag = 0;
18603 26 }
18604 114 }
18605
18606
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 setup_combo_animations();
18607
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 setup_combo_animations2();
18608 114 return 0;
18609 114 }
18610
18611 105 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18612 {
18613 //these are here to bypass compiler warnings about unused arguments
18614 105 Header=Header;
18615 105 version=version;
18616 105 build=build;
18617
18618 int32_t dummy;
18619 105 word sversion=0, c_sversion;
18620
18621 //section version info
18622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&sversion,f,true))
18623 {
18624 return qe_invalid;
18625 }
18626
18627 105 FFCore.quest_format[vComboAliases] = sversion;
18628
18629 //al_trace("Combo aliases version %d\n", sversion);
18630
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&c_sversion,f,true))
18631 {
18632 return qe_invalid;
18633 }
18634
18635 //section size
18636
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
18637 {
18638 return qe_invalid;
18639 }
18640
18641 105 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18642
18643
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18644 {
18645 76 max_num_combo_aliases = MAX250COMBOALIASES;
18646 76 }
18647
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18648 {
18649 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18650 }
18651
18652
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 105 times.
393321 for(int32_t j=0; j<max_num_combo_aliases; j++)
18653 {
18654 byte width,height,mask,tempcset;
18655 int32_t count;
18656 word tempword;
18657 byte tempbyte;
18658
18659
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_igetw(&tempword,f,true))
18660 {
18661 return qe_invalid;
18662 }
18663
18664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18665 {
18666 393216 combo_aliases[j].combo = tempword;
18667 393216 }
18668
18669
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&tempbyte,f,true))
18670 {
18671 return qe_invalid;
18672 }
18673
18674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18675 {
18676 393216 combo_aliases[j].cset = tempbyte;
18677 393216 }
18678
18679
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&width,f,true))
18680 {
18681 return qe_invalid;
18682 }
18683
18684
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&height,f,true))
18685 {
18686 return qe_invalid;
18687 }
18688
18689
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&mask,f,true))
18690 {
18691 return qe_invalid;
18692 }
18693
18694 393216 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18695
18696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18697 {
18698
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(combo_aliases[j].combos != NULL)
18699 {
18700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 delete[] combo_aliases[j].combos;
18701 393216 }
18702
18703
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(combo_aliases[j].csets != NULL)
18704 {
18705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 delete[] combo_aliases[j].csets;
18706 393216 }
18707
18708 393216 combo_aliases[j].width = width;
18709 393216 combo_aliases[j].height = height;
18710 393216 combo_aliases[j].layermask = mask;
18711 393216 combo_aliases[j].combos = new word[count];
18712 393216 combo_aliases[j].csets = new byte[count];
18713 393216 }
18714
18715
2/2
✓ Branch 0 taken 402693 times.
✓ Branch 1 taken 393216 times.
795909 for(int32_t k=0; k<count; k++)
18716 {
18717
1/2
✓ Branch 0 taken 402693 times.
✗ Branch 1 not taken.
402693 if(!p_igetw(&tempword,f,true))
18718 {
18719 return qe_invalid;
18720 }
18721
18722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402693 times.
402693 if(keepdata)
18723 {
18724 402693 combo_aliases[j].combos[k] = tempword;
18725 402693 }
18726 402693 }
18727
18728
2/2
✓ Branch 0 taken 402693 times.
✓ Branch 1 taken 393216 times.
795909 for(int32_t k=0; k<count; k++)
18729 {
18730
1/2
✓ Branch 0 taken 402693 times.
✗ Branch 1 not taken.
402693 if(!p_getc(&tempcset,f,true))
18731 {
18732 return qe_invalid;
18733 }
18734
18735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402693 times.
402693 if(keepdata)
18736 {
18737 402693 combo_aliases[j].csets[k] = tempcset;
18738 402693 }
18739 402693 }
18740 393216 }
18741
18742 105 word num_combo_pools = 0;
18743
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 27 times.
105 if(sversion >= 4)
18744 {
18745
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&num_combo_pools,f,true))
18746 {
18747 return qe_invalid;
18748 }
18749 27 }
18750
18751
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 105 times.
860265 for(combo_pool& pool : combo_pools)
18752 {
18753 860160 pool.clear();
18754 }
18755
18756 105 combo_pool temp_cpool;
18757
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 105 times.
177 for(word cp = 0; cp < num_combo_pools; ++cp)
18758 {
18759 72 int32_t num_combos_in_pool = 0;
18760
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 if(!p_igetl(&num_combos_in_pool,f,true))
18761 {
18762 return qe_invalid;
18763 }
18764
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(num_combos_in_pool < 1) continue; //nothing to read
18765
18766
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 temp_cpool.clear();
18767
18768 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18769
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 72 times.
384 for(auto q = 0; q < num_combos_in_pool; ++q)
18770 {
18771
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_igetl(&cp_cid,f,true))
18772 {
18773 return qe_invalid;
18774 }
18775
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_getc(&cp_cs,f,true))
18776 {
18777 return qe_invalid;
18778 }
18779
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_igetw(&cp_quant,f,true))
18780 {
18781 return qe_invalid;
18782 }
18783
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18784 312 }
18785
18786
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(keepdata)
18787 {
18788
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 combo_pools[cp] = temp_cpool;
18789 72 }
18790 72 }
18791
18792 105 return 0;
18793 105 }
18794
18795 114 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18796 {
18797 //these are here to bypass compiler warnings about unused arguments
18798
18799 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18800 //Capitalized cause it'll save you a headache. -Deedee
18801 114 start_cset=start_cset;
18802 114 max_csets=max_csets;
18803 114 word s_version=0;
18804
18805 miscQdata temp_misc;
18806 114 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18807
18808 byte temp_colordata[48];
18809 char temp_palname[PALNAMESIZE];
18810
18811 int32_t dummy;
18812 word palcycles;
18813
18814
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
18815 {
18816 //section version info
18817
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
18818 {
18819 return qe_invalid;
18820 }
18821
18822 110 FFCore.quest_format[vCSets] = s_version;
18823
18824 //al_trace("Color data version %d\n", s_version);
18825
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
18826 {
18827 return qe_invalid;
18828 }
18829
18830 //section size
18831
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
18832 {
18833 return qe_invalid;
18834 }
18835 110 }
18836
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if (s_version < 5)
18837 {
18838
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
85 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18839
18840 //finally... section data
18841 85 int32_t q = 0;
18842 85 int32_t p = -15;
18843
2/2
✓ Branch 0 taken 20400 times.
✓ Branch 1 taken 85 times.
20485 for(int32_t i=0; i<oldpdTOTAL; ++i)
18844 {
18845 20400 memset(temp_colordata, 0, 48);
18846
18847
1/2
✓ Branch 0 taken 20400 times.
✗ Branch 1 not taken.
20400 if(!pfread(temp_colordata,48,f,true))
18848 {
18849 return qe_invalid;
18850 }
18851
18852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20400 times.
20400 if(keepdata==true)
18853 {
18854 20400 memcpy(&colordata[q*48], temp_colordata, 48);
18855 20400 }
18856 20400 ++q;
18857
8/8
✓ Branch 0 taken 19040 times.
✓ Branch 1 taken 1360 times.
✓ Branch 2 taken 1445 times.
✓ Branch 3 taken 17595 times.
✓ Branch 4 taken 170 times.
✓ Branch 5 taken 1275 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 162 times.
20400 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18858 {
18859
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if (s_version < 5) //Bumping up the size of level palettes
18860 {
18861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1437 times.
1437 if(keepdata==true)
18862 {
18863 1437 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18864 1437 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18865 1437 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18866 1437 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18867 1437 }
18868 1437 q+=4;
18869 1437 }
18870 else
18871 {
18872 for(int m = 0; m < 4; ++m)
18873 {
18874 memset(temp_colordata, 0, 48);
18875 if(!pfread(temp_colordata,48,f,true))
18876 {
18877 return qe_invalid;
18878 }
18879 if(keepdata==true)
18880 {
18881 memcpy(&colordata[q*48], temp_colordata, 48);
18882 }
18883 ++q;
18884 }
18885 }
18886 1437 }
18887 20400 ++p;
18888 20400 }
18889
18890
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
85 if(RealOldVerion)
18891 {
18892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18893 {
18894 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18895 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18896 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18897 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18898 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18899 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18900 4 }
18901 4 }
18902 else
18903 {
18904 81 memset(temp_colordata, 0, 48);
18905
18906
2/2
✓ Branch 0 taken 253773 times.
✓ Branch 1 taken 81 times.
253854 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18907 {
18908
1/2
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
253773 if(!pfread(temp_colordata,48,f,true))
18909 {
18910 return qe_invalid;
18911 }
18912
18913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253773 times.
253773 if(keepdata==true)
18914 {
18915 253773 memcpy(&colordata[q*48], temp_colordata, 48);
18916 253773 }
18917 253773 ++q;
18918
7/8
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19521 times.
✓ Branch 3 taken 234252 times.
✓ Branch 4 taken 162 times.
✓ Branch 5 taken 19359 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 10 times.
253773 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18919 {
18920
1/2
✓ Branch 0 taken 19511 times.
✗ Branch 1 not taken.
19511 if (s_version < 5) //Bumping up the size of level palettes
18921 {
18922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19511 times.
19511 if(keepdata==true)
18923 {
18924 19511 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18925 19511 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18926 19511 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18927 19511 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18928 19511 }
18929 19511 q+=4;
18930 19511 }
18931 else
18932 {
18933 for(int m = 0; m < 4; ++m)
18934 {
18935 memset(temp_colordata, 0, 48);
18936 if(!pfread(temp_colordata,48,f,true))
18937 {
18938 return qe_invalid;
18939 }
18940 if(keepdata==true)
18941 {
18942 memcpy(&colordata[q*48], temp_colordata, 48);
18943 }
18944 ++q;
18945 }
18946 }
18947 19511 }
18948 253773 ++p;
18949 253773 }
18950
18951
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 76 times.
81 if(s_version < 4)
18952 {
18953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18954 {
18955 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18956 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18957 5 }
18958 5 }
18959 else
18960 {
18961
2/2
✓ Branch 0 taken 252928 times.
✓ Branch 1 taken 76 times.
253004 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18962 {
18963
1/2
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
252928 if(!pfread(temp_colordata,48,f,true))
18964 {
18965 return qe_invalid;
18966 }
18967
18968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252928 times.
252928 if(keepdata==true)
18969 {
18970 252928 memcpy(&colordata[q*48], temp_colordata, 48);
18971 252928 }
18972 252928 ++q;
18973
5/6
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✓ Branch 3 taken 233472 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 19304 times.
252928 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18974 {
18975
1/2
✓ Branch 0 taken 19304 times.
✗ Branch 1 not taken.
19304 if (s_version < 5) //Bumping up the size of level palettes
18976 {
18977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19304 times.
19304 if(keepdata==true)
18978 {
18979 19304 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18980 19304 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18981 19304 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18982 19304 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18983 19304 }
18984 19304 q+=4;
18985 19304 }
18986 else
18987 {
18988 for(int m = 0; m < 4; ++m)
18989 {
18990 memset(temp_colordata, 0, 48);
18991 if(!pfread(temp_colordata,48,f,true))
18992 {
18993 return qe_invalid;
18994 }
18995 if(keepdata==true)
18996 {
18997 memcpy(&colordata[q*48], temp_colordata, 48);
18998 }
18999 ++q;
19000 }
19001 }
19002 19304 }
19003 252928 ++p;
19004 252928 }
19005
19006 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19007 }
19008 }
19009 85 }
19010 else
19011 {
19012
2/2
✓ Branch 0 taken 253721 times.
✓ Branch 1 taken 29 times.
253750 for(int32_t i=0; i<pdTOTAL255; ++i)
19013 {
19014 253721 memset(temp_colordata, 0, 48);
19015
19016
1/2
✓ Branch 0 taken 253721 times.
✗ Branch 1 not taken.
253721 if(!pfread(temp_colordata,48,f,true))
19017 {
19018 return qe_invalid;
19019 }
19020
19021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253721 times.
253721 if(keepdata==true)
19022 {
19023 253721 memcpy(&colordata[i*48], temp_colordata, 48);
19024 253721 }
19025 253721 }
19026 }
19027
19028
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x192)||((version == 0x192)&&(build<76)))
19029 {
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19031 {
19032 4 init_palnames();
19033 4 }
19034 4 }
19035 else
19036 {
19037 110 int32_t palnamestoread = 0;
19038
19039
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 3)
19040 5 palnamestoread = OLDMAXLEVELS;
19041 else
19042 105 palnamestoread = 512;
19043
19044
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 110 times.
55150 for(int32_t i=0; i<palnamestoread; ++i)
19045 {
19046 55040 memset(temp_palname, 0, PALNAMESIZE);
19047
19048
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19049 {
19050 return qe_invalid;
19051 }
19052
19053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(keepdata==true)
19054 {
19055 55040 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19056 55040 }
19057 55040 }
19058
19059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata)
19060 {
19061
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 110 times.
1390 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19062 {
19063 1280 memset(palnames[i], 0, PALNAMESIZE);
19064 1280 }
19065 110 }
19066 }
19067
19068
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
19069 {
19070
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 110 times.
28270 for(int32_t i=0; i<256; i++)
19071 {
19072
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 28160 times.
112640 for(int32_t j=0; j<3; j++)
19073 {
19074 84480 temp_misc.cycles[i][j].first=0;
19075 84480 temp_misc.cycles[i][j].count=0;
19076 84480 temp_misc.cycles[i][j].speed=0;
19077 84480 }
19078 28160 }
19079
19080
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&palcycles,f,true))
19081 {
19082 return qe_invalid;
19083 }
19084
19085
2/2
✓ Branch 0 taken 3448 times.
✓ Branch 1 taken 110 times.
3558 for(int32_t i=0; i<palcycles; i++)
19086 {
19087
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19088 {
19089
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19090 {
19091 return qe_invalid;
19092 }
19093 10344 }
19094
19095
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19096 {
19097
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19098 {
19099 return qe_invalid;
19100 }
19101 10344 }
19102
19103
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19104 {
19105
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19106 {
19107 return qe_invalid;
19108 }
19109 10344 }
19110 3448 }
19111
19112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
19113 {
19114 110 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19115 110 }
19116 110 }
19117
19118 114 return 0;
19119 114 }
19120
19121 114 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19122 {
19123 114 int32_t tiles_used=0;
19124 114 word section_version = 0;
19125 114 word section_cversion = 0;
19126 114 int32_t section_size= 0;
19127 114 byte *temp_tile = new byte[tilesize(tf32Bit)];
19128
19129 //Tile Expansion
19130 //if ( version >= 0x254 && build >= 41 )
19131
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
114 if (version < 0x254 && build < 41)
19132 {
19133 //al_trace("Build was < 41 when reading tiles\n");
19134 85 max_tiles = ZC250MAXTILES;
19135 85 }
19136
19137 //al_trace("Max Tiles: %d\n", max_tiles);
19138
19139
2/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19140 {
19141 if(keepdata==true)
19142 {
19143 if(!init_tiles(true, Header))
19144 {
19145 al_trace("Unable to initialize tiles\n");
19146 }
19147 }
19148
19149 delete[] temp_tile;
19150 temp_tile=NULL;
19151 return 0;
19152 }
19153 else
19154 {
19155
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
19156 {
19157 //section version info
19158
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_version,f,true))
19159 {
19160 delete[] temp_tile;
19161 return qe_invalid;
19162 }
19163
19164 110 FFCore.quest_format[vTiles] = section_version;
19165
19166
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_cversion,f,true))
19167 {
19168 delete[] temp_tile;
19169 return qe_invalid;
19170 }
19171
19172 //section size
19173
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&section_size,f,true))
19174 {
19175 delete[] temp_tile;
19176 return qe_invalid;
19177 }
19178 110 }
19179
19180 //if ( build < 41 )
19181 //{
19182 // tiles_used = ZC250MAXTILES;
19183 //}
19184
19185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(version < 0x174)
19186 {
19187 tiles_used=TILES_PER_PAGE*4;
19188 } //no expanded tile space
19189
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 else if(version < 0x191)
19190 {
19191 4 tiles_used=OLDMAXTILES;
19192 4 }
19193 else
19194 {
19195 //finally... section data
19196
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
110 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19197 {
19198
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tiles_used,f,true))
19199 {
19200 delete[] temp_tile;
19201 return qe_invalid;
19202 }
19203 29 }
19204 else
19205 {
19206
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetw(&tiles_used,f,true))
19207 {
19208 delete[] temp_tile;
19209 return qe_invalid;
19210 }
19211 }
19212 }
19213
19214
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 tiles_used=zc_min(tiles_used, max_tiles);
19215
19216 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19217 //if ( version < 0x254 && build < 41 )
19218
3/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if ( version < 0x254 || (version == 0x254 && build < 41) )
19219 //if ( build < 41 )
19220 {
19221
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19222 85 }
19223 else //2.55
19224 {
19225
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19226 }
19227
19228 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19229
19230 //al_trace("tiles_used = %d\n", tiles_used);
19231
19232
2/2
✓ Branch 0 taken 2707919 times.
✓ Branch 1 taken 114 times.
2708033 for(int32_t i=0; i<tiles_used; ++i)
19233 {
19234 2707919 byte format=tf4Bit;
19235 2707919 memset(temp_tile, 0, tilesize(tf32Bit));
19236
19237
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2535681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2707919 if((version>0x211)||((version==0x211)&&(build>4)))
19238 {
19239
1/2
✓ Branch 0 taken 2535681 times.
✗ Branch 1 not taken.
2535681 if(!p_getc(&format,f,true))
19240 {
19241 delete[] temp_tile;
19242 return qe_invalid;
19243 }
19244 2535681 }
19245
4/4
✓ Branch 0 taken 995916 times.
✓ Branch 1 taken 1712003 times.
✓ Branch 2 taken 490725 times.
✓ Branch 3 taken 505191 times.
2707919 if(section_version > 2 && !format)
19246 {
19247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 505191 times.
505191 if(keepdata)
19248 {
19249 505191 reset_tile(buf,start_tile+i,tf4Bit);
19250 505191 }
19251 505191 continue;
19252 }
19253
19254
1/2
✓ Branch 0 taken 2202728 times.
✗ Branch 1 not taken.
2202728 if(!pfread(temp_tile,tilesize(format),f,true))
19255 {
19256 delete[] temp_tile;
19257 return qe_invalid;
19258 }
19259
19260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2202728 times.
2202728 if(keepdata==true)
19261 {
19262 2202728 buf[start_tile+i].format=format;
19263
19264
1/2
✓ Branch 0 taken 2202728 times.
✗ Branch 1 not taken.
2202728 if(buf[start_tile+i].data)
19265 {
19266 2202728 free(buf[start_tile+i].data);
19267 2202728 buf[start_tile+i].data=NULL;
19268 2202728 }
19269
19270 2202728 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19271 2202728 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19272 2202728 }
19273 2202728 }
19274 }
19275
19276
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19277 {
19278 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19279
2/2
✓ Branch 0 taken 12663300 times.
✓ Branch 1 taken 85 times.
12663385 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19280 {
19281
19282 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19283 12663300 reset_tile(buf,q,tf4Bit);
19284
19285
19286 /*
19287
19288 byte tempbyte;
19289 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19290 {
19291 tempbyte=buf[ZC250MAXTILES-1].data[i];
19292 buf[q].data[i] = tempbyte;
19293 }
19294 //int32_t temp = tempbyte=buf[130].data[i];
19295 //buf[q].data = buf[ZC250MAXTILES-1].data;
19296 */
19297 //reset_tile(buf,q,tf4Bit);
19298 12663300 }
19299
19300 85 }
19301
19302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19303 {
19304
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19305 {
19306
2/2
✓ Branch 0 taken 4065817 times.
✓ Branch 1 taken 85 times.
4065902 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19307 {
19308 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19309 4065817 reset_tile(buf,i,tf4Bit);
19310 4065817 }
19311 85 }
19312 else
19313 {
19314
2/2
✓ Branch 0 taken 5015964 times.
✓ Branch 1 taken 29 times.
5015993 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19315 {
19316 //al_trace("Resetting tiles for build 41+\n");
19317 5015964 reset_tile(buf,i,tf4Bit);
19318 5015964 }
19319 }
19320
19321
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19322 {
19323
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19324 {
19325 byte tempbyte;
19326 int32_t floattile=wpnsbuf[iwSwim].tile;
19327
19328 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19329 {
19330 tempbyte=buf[23].data[i];
19331 buf[23].data[i]=buf[24].data[i];
19332 buf[24].data[i]=buf[25].data[i];
19333 buf[25].data[i]=buf[26].data[i];
19334 buf[26].data[i]=tempbyte;
19335 }
19336 //swim tiles are out of order, too, but nobody cared? -Z
19337 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19338 {
19339 tempbyte=buf[floattile+11].data[i];
19340 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19341 buf[floattile+12].data[i]=tempbyte;
19342 }
19343 }
19344 4 }
19345
19346
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19347 {
19348
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19349 {
19350 byte tempbyte;
19351
19352
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19353 {
19354 512 tempbyte=buf[130].data[i];
19355 512 buf[130].data[i]=buf[132].data[i];
19356 512 buf[132].data[i]=tempbyte;
19357
19358 512 tempbyte=buf[131].data[i];
19359 512 buf[131].data[i]=buf[133].data[i];
19360 512 buf[133].data[i]=tempbyte;
19361 512 }
19362 4 }
19363 9 }
19364
19365 114 al_trace("Registering blank tiles\n");
19366 114 register_blank_tiles();
19367 114 }
19368
19369 //memset(temp_tile, 0, tilesize(tf32Bit));
19370
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 delete[] temp_tile;
19371 114 temp_tile=NULL;
19372 114 return 0;
19373 114 }
19374
19375 114 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19376 {
19377 114 byte *mf=midi_flags;
19378 int32_t dummy;
19379 word dummy2;
19380 // zcmidi_ temp_midi;
19381 int32_t tunes_to_read;
19382 114 int32_t tune_count=0;
19383 114 word section_version=0;
19384 114 zctune temp;
19385
19386
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version < 0x193)
19387 {
19388 // mf=Header->data_flags+ZQ_MIDIS2;
19389
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19390 {
19391 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19392 4 }
19393 else
19394 {
19395 tunes_to_read=MAXCUSTOMTUNES;
19396 }
19397 4 }
19398 else
19399 {
19400 //section version info
19401
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_version,f,true))
19402 {
19403 return qe_invalid;
19404 }
19405
19406 110 FFCore.quest_format[vMIDIs] = section_version;
19407
19408 //al_trace("Tunes version %d\n", section_version);
19409
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy2,f,true))
19410 {
19411 return qe_invalid;
19412 }
19413
19414 //section size
19415
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
19416 {
19417 return qe_invalid;
19418 }
19419
19420 //finally... section data
19421
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19422 {
19423 return qe_invalid;
19424 }
19425
19426 110 tunes_to_read=MAXCUSTOMTUNES;
19427 }
19428
19429
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19430 {
19431
2/2
✓ Branch 0 taken 26853 times.
✓ Branch 1 taken 1875 times.
28728 if(get_bit(mf, i))
19432 {
19433 1875 ++tune_count;
19434 1875 }
19435 28728 }
19436
19437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19438 {
19439 114 reset_tunes(tunes); //reset_midis(midis);
19440 114 }
19441
19442
2/2
✓ Branch 0 taken 27848 times.
✓ Branch 1 taken 114 times.
27962 for(int32_t i=0; i<tunes_to_read; i++)
19443 {
19444 27848 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19445
19446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27848 times.
27848 if(keepdata==true)
19447 {
19448 27848 tunes[i].reset(); // reset_midi(midis+i);
19449 27848 }
19450
19451
2/2
✓ Branch 0 taken 25973 times.
✓ Branch 1 taken 1875 times.
27848 if(get_bit(mf,i))
19452 {
19453
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version < 4)
19454 {
19455
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19456 {
19457 return qe_invalid;
19458 }
19459 297 }
19460 else
19461 {
19462
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19463 {
19464 return qe_invalid;
19465 }
19466 }
19467
19468
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.start,f,true))
19469 {
19470 return qe_invalid;
19471 }
19472
19473
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.loop_start,f,true))
19474 {
19475 return qe_invalid;
19476 }
19477
19478
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.loop_end,f,true))
19479 {
19480 return qe_invalid;
19481 }
19482
19483
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetw(&temp.loop,f,true))
19484 {
19485 return qe_invalid;
19486 }
19487
19488
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetw(&temp.volume,f,true))
19489 {
19490 return qe_invalid;
19491 }
19492
19493
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 78 times.
1875 if(Header->zelda_version < 0x193)
19494 {
19495
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19496 {
19497 return qe_invalid;
19498 }
19499 78 }
19500
19501
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version >= 3)
19502 {
19503
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19504 {
19505 return qe_invalid;
19506 }
19507 1578 }
19508
19509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875 times.
1875 if(keepdata==true)
19510 {
19511 1875 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19512 1875 }
19513
19514
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19515 {
19516 // old format - a midi is a midi
19517
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19518 {
19519 return qe_invalid;
19520 }
19521
19522 //yes you can do this. Isn't the ? operator awesome? :)
19523
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19524 297 }
19525 else
19526 {
19527 // 'midi' could be midi or nes, gb, ... music
19528
2/4
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1578 times.
✗ Branch 3 not taken.
1578 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19529 {
19530 return qe_invalid;
19531 }
19532
19533
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19534
19535
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 switch(temp.format)
19536 {
19537 case MFORMAT_MIDI:
19538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1578 times.
1578 if((ptr->data=read_midi(f, true))==NULL)
19539 {
19540 return qe_invalid;
19541 }
19542
19543 1578 break;
19544
19545 default:
19546 return qe_invalid;
19547 break;
19548 }
19549 }
19550 1875 }
19551 27848 }
19552
19553 114 return 0;
19554 114 }
19555
19556 114 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19557 {
19558 int32_t dummy;
19559 ZCHEATS tempzcheats;
19560 114 char temp_use_cheats=1;
19561 114 memset(&tempzcheats, 0, sizeof(tempzcheats));
19562 114 word s_version = 0;
19563
19564
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
19565 {
19566 //section version info
19567
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
19568 {
19569 return qe_invalid;
19570 }
19571
19572 110 FFCore.quest_format[vCheats] = s_version;
19573 //al_trace("Cheats version %d\n", dummy);
19574
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
19575 {
19576 return qe_invalid;
19577 }
19578
19579 //section size
19580
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
19581 {
19582 return qe_invalid;
19583 }
19584
19585 //finally... section data
19586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_getc(&temp_use_cheats,f,true))
19587 {
19588 return qe_invalid;
19589 }
19590 110 }
19591
19592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(Header->data_flags[ZQ_CHEATS2])
19593 {
19594
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempzcheats.flags,f,true))
19595 {
19596 return qe_invalid;
19597 }
19598
19599
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19600 {
19601 return qe_invalid;
19602 }
19603 114 }
19604
19605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19606 {
19607 114 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19608 114 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19609 114 }
19610
19611 114 return 0;
19612 114 }
19613
19614 278 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19615 {
19616 int32_t dummy;
19617 278 word s_version=0, s_cversion=0;
19618 byte padding;
19619 word tempw;
19620
19621 278 zinitdata temp_zinit;
19622
19623 // Legacy item properties (now integrated into itemdata)
19624 byte sword_hearts[4];
19625 byte beam_hearts[4];
19626 278 byte beam_percent=0;
19627 word beam_power[4];
19628 278 byte hookshot_length=99;
19629 278 byte hookshot_links=100;
19630 278 byte longshot_length=99;
19631 278 byte longshot_links=100;
19632 278 byte moving_fairy_hearts=3;
19633 278 byte moving_fairy_heart_percent=0;
19634 278 byte stationary_fairy_hearts=3;
19635 278 byte stationary_fairy_heart_percent=0;
19636 278 byte moving_fairy_magic=0;
19637 278 byte moving_fairy_magic_percent=0;
19638 278 byte stationary_fairy_magic=0;
19639 278 byte stationary_fairy_magic_percent=0;
19640 278 byte blue_potion_hearts=100;
19641 278 byte blue_potion_heart_percent=1;
19642 278 byte red_potion_hearts=100;
19643 278 byte red_potion_heart_percent=1;
19644 278 byte blue_potion_magic=100;
19645 278 byte blue_potion_magic_percent=1;
19646 278 byte red_potion_magic=100;
19647 278 byte red_potion_magic_percent=1;
19648
19649
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 164 times.
278 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19650
19651
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version > 0x192)
19652 {
19653 //section version info
19654
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_version,f,true))
19655 {
19656 return qe_invalid;
19657 }
19658
19659 110 FFCore.quest_format[vInitData] = s_version;
19660
19661 //al_trace("Init data version %d\n", s_version);
19662
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_cversion,f,true))
19663 {
19664 return qe_invalid;
19665 }
19666
19667 //section size
19668
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy,f,true))
19669 {
19670 return qe_invalid;
19671 }
19672 110 }
19673
19674 /* HIGHLY UNORTHODOX UPDATING THING, by L
19675 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19676 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19677 * changing from 13 to 14.
19678 */
19679
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 9 times.
114 if(keepdata && s_version < 14)
19680 9 fixpolsvoice=true;
19681
19682 /* End highly unorthodox updating thing */
19683
19684
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 31 times.
114 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19685 31 temp_zinit.jump_hero_layer_threshold=0;
19686
19687
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version >= 10)
19688 {
19689 char temp;
19690
19691 //new-style items
19692
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t j=0; j<256; j++)
19693 {
19694
2/4
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26880 times.
26880 if(!p_getc(&temp,f,true))
19695 return qe_invalid;
19696
19697 26880 temp_zinit.items[j] = (temp != 0);
19698 26880 }
19699 105 }
19700
19701
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 54 times.
114 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19702 {
19703 char temp;
19704
19705 //finally... section data
19706
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 54 times.
164 if((Header->zelda_version > 0x192)||
19707 //new only
19708 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19709 {
19710 //OLD-style items... sigh
19711
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 10)
19712 {
19713
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19714 {
19715 return qe_invalid;
19716 }
19717
19718 5 temp_zinit.items[iRaft]=(temp != 0);
19719
19720
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19721 {
19722 return qe_invalid;
19723 }
19724
19725 5 temp_zinit.items[iLadder]=(temp != 0);
19726
19727
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19728 {
19729 return qe_invalid;
19730 }
19731
19732 5 temp_zinit.items[iBook]=(temp != 0);
19733
19734
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19735 {
19736 return qe_invalid;
19737 }
19738
19739 5 temp_zinit.items[iMKey]=(temp!=0);
19740
19741
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19742 {
19743 return qe_invalid;
19744 }
19745
19746 5 temp_zinit.items[iFlippers]=(temp != 0);
19747
19748
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19749 {
19750 return qe_invalid;
19751 }
19752
19753 5 temp_zinit.items[iBoots]=(temp!=0);
19754 5 }
19755 110 }
19756
19757
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 157 times.
164 if(s_version < 10)
19758 {
19759 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19760
19761
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19762 {
19763 return qe_invalid;
19764 }
19765
19766
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19772 {
19773 return qe_invalid;
19774 }
19775
19776
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19777 {
19778 return qe_invalid;
19779 }
19780
19781
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19782 {
19783 return qe_invalid;
19784 }
19785
19786
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19787 {
19788 return qe_invalid;
19789 }
19790
19791
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19792 {
19793 return qe_invalid;
19794 }
19795
19796 //old only
19797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19798 {
19799 tempring=(tempring)?(1<<(tempring-1)):0;
19800 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19801 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19802 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19803 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19804 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19805 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19806 }
19807
19808 //rings start at level 2... wtf
19809 //account for this -DD
19810 5 tempring <<= 1;
19811
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19812
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19813
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19814
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19815 //bracelet ALSO starts at level 2 :-( -DD
19816 5 tempbracelet<<=1;
19817
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19818
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19819
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19820
19821 //new only
19822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19823 {
19824 for(int32_t q=0; q<32; q++)
19825 {
19826 if(!p_getc(&padding,f,true))
19827 {
19828 return qe_invalid;
19829 }
19830 }
19831 }
19832
19833 char tempcandle, tempboomerang, temparrow, tempwhistle;
19834
19835
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19836 {
19837 return qe_invalid;
19838 }
19839
19840
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19841 {
19842 return qe_invalid;
19843 }
19844
19845
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19846 {
19847 return qe_invalid;
19848 }
19849
19850
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19851 {
19852 return qe_invalid;
19853 }
19854
19855
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19856
19857
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19858 {
19859 return qe_invalid;
19860 }
19861
19862 //old only
19863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19864 {
19865 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19866 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19867 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19868 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19869 }
19870
19871
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19872
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19873
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19874
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19875 //What about the potion...?
19876
19877 5 }
19878
19879
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 81 times.
162 if(s_version < 29)
19880 {
19881 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19882 //to jab out my eye...
19883
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19884 return qe_invalid;
19885 81 temp_zinit.bombs = padding;
19886
19887
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19888 return qe_invalid;
19889 81 temp_zinit.super_bombs = padding;
19890 81 }
19891
19892 //Back to more OLD item code
19893
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
162 if(s_version < 10)
19894 {
19895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19896 //new only
19897 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19898 {
19899
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19900 {
19901 return qe_invalid;
19902 }
19903
19904
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19905
19906
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19907 {
19908 return qe_invalid;
19909 }
19910
19911
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19912
19913
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19914 {
19915 return qe_invalid;
19916 }
19917
19918
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19919
19920
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19921 {
19922 return qe_invalid;
19923 }
19924
19925
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19926
19927
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19928 {
19929 return qe_invalid;
19930 }
19931
19932
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19933
19934
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19935 {
19936 return qe_invalid;
19937 }
19938
19939
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19940
19941
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19942 {
19943 return qe_invalid;
19944 }
19945
19946
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19947
19948
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19949 {
19950 return qe_invalid;
19951 }
19952
19953
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19954
19955
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19956 {
19957 return qe_invalid;
19958 }
19959
19960
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19961
19962
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19963 {
19964 return qe_invalid;
19965 }
19966
19967
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19968 {
19969 for(int32_t q=0; q<32; q++)
19970 {
19971 if(!p_getc(&padding,f,true))
19972 {
19973 return qe_invalid;
19974 }
19975 }
19976 }
19977 5 }
19978 5 }
19979
19980 //old only
19981
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19982 {
19983 byte equipment, items; //bit flags
19984
19985 if(!p_getc(&equipment,f,true))
19986 {
19987 return qe_invalid;
19988 }
19989
19990 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19991 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19992 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19993 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19994 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19995 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19996
19997
19998 if(!p_getc(&items,f,true))
19999 {
20000 return qe_invalid;
20001 }
20002
20003 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
20004 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
20005 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
20006 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
20007 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
20008 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
20009 }
20010
20011 if(!p_getc(&temp_zinit.hc,f,true))
20012 {
20013 return qe_invalid;
20014 }
20015
20016
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 14)
20017 {
20018 byte temphp;
20019
20020
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20021 {
20022 return qe_invalid;
20023 }
20024
20025 5 temp_zinit.start_heart=temphp;
20026
20027
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20028 {
20029 return qe_invalid;
20030 }
20031
20032 5 temp_zinit.cont_heart=temphp;
20033 5 }
20034 else
20035 {
20036
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.start_heart,f,true))
20037 {
20038 return qe_invalid;
20039 }
20040
20041
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20042 {
20043 return qe_invalid;
20044 }
20045 }
20046
20047
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.hcp,f,true))
20048 {
20049 return qe_invalid;
20050 }
20051
20052
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version >= 14)
20053 {
20054
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20055 {
20056 return qe_invalid;
20057 }
20058
20059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version<16) // July 2007
20060 {
20061 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20062 temp_zinit.hcp_per_hc = 0xFF;
20063
20064 //Dispose of legacy rule
20065 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20066 }
20067 105 }
20068
20069
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version < 29)
20070 {
20071
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20072 return qe_invalid;
20073 81 temp_zinit.max_bombs = padding;
20074 81 }
20075
20076
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.keys,f,true))
20077 {
20078 return qe_invalid;
20079 }
20080
20081
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&temp_zinit.rupies,f,true))
20082 {
20083 return qe_invalid;
20084 }
20085
20086
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.triforce,f,true))
20087 {
20088 return qe_invalid;
20089 }
20090
20091
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20092 {
20093
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20094 {
20095
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.map[i],f,true))
20096 {
20097 return qe_invalid;
20098 }
20099 6720 }
20100
20101
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20102 {
20103
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.compass[i],f,true))
20104 {
20105 return qe_invalid;
20106 }
20107 6720 }
20108 105 }
20109 else
20110 {
20111
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20112 {
20113
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20114 {
20115 return qe_invalid;
20116 }
20117 160 }
20118
20119
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20120 {
20121
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20122 {
20123 return qe_invalid;
20124 }
20125 160 }
20126 }
20127
20128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version > 0x192)||
20129 //new only
20130 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20131 {
20132
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20133 {
20134
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20135 {
20136
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20137 {
20138 return qe_invalid;
20139 }
20140 6720 }
20141 105 }
20142 else
20143 {
20144
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20145 {
20146
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20147 {
20148 return qe_invalid;
20149 }
20150 160 }
20151 }
20152 110 }
20153
20154
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 1760 times.
1870 for(int32_t i=0; i<16; i++)
20155 {
20156
2/4
✓ Branch 0 taken 1760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1760 times.
1760 if(!p_getc(&temp_zinit.misc[i],f,true))
20157 {
20158 return qe_invalid;
20159 }
20160 1760 }
20161
20162
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
130 if(s_version < 15) for(int32_t i=0; i<4; i++)
20163 {
20164
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20165 {
20166 return qe_invalid;
20167 }
20168 25 }
20169
20170
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.last_map,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174
20175
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.last_screen,f,true))
20176 {
20177 return qe_invalid;
20178 }
20179
20180
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 14)
20181 {
20182 byte tempmp;
20183
20184
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20185 {
20186 return qe_invalid;
20187 }
20188
20189 5 temp_zinit.max_magic=tempmp;
20190
20191
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20192 {
20193 return qe_invalid;
20194 }
20195
20196 5 temp_zinit.magic=tempmp;
20197 5 }
20198 else
20199 {
20200
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_magic,f,true))
20201 {
20202 return qe_invalid;
20203 }
20204
20205
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.magic,f,true))
20206 {
20207 return qe_invalid;
20208 }
20209 }
20210
20211
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version < 15)
20212 {
20213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20214 {
20215 5 temp_zinit.max_magic*=32;
20216 5 temp_zinit.magic*=32;
20217 5 }
20218
20219
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20220 {
20221
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20222 {
20223 return qe_invalid;
20224 }
20225 20 }
20226
20227
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20228 {
20229 return qe_invalid;
20230 }
20231 5 }
20232 else
20233 {
20234
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20235 {
20236 return qe_invalid;
20237 }
20238 }
20239
20240
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version < 15)
20241 {
20242 byte tempbp;
20243
20244
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20245 {
20246
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20247 {
20248 return qe_invalid;
20249 }
20250
20251 20 beam_power[i]=tempbp;
20252 20 }
20253
20254
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20255 {
20256 return qe_invalid;
20257 }
20258
20259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20260 {
20261 if(!p_getc(&hookshot_length,f,true))
20262 {
20263 return qe_invalid;
20264 }
20265
20266 if(!p_getc(&longshot_links,f,true))
20267 {
20268 return qe_invalid;
20269 }
20270
20271 if(!p_getc(&longshot_length,f,true))
20272 {
20273 return qe_invalid;
20274 }
20275 }
20276 5 }
20277
20278
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20279 {
20280 return qe_invalid;
20281 }
20282
20283
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20284 {
20285 return qe_invalid;
20286 }
20287
20288
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.subscreen,f,true))
20289 {
20290 return qe_invalid;
20291 }
20292
20293 //old only
20294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version == 0x192)&&(Header->build<174))
20295 {
20296 for(int32_t i=0; i<32; i++)
20297 {
20298 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20299 {
20300 return qe_invalid;
20301 }
20302 }
20303 }
20304
20305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20306 {
20307
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version <= 10)
20308 {
20309 byte tempbyte;
20310
20311
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20312 {
20313 return qe_invalid;
20314 }
20315
20316 5 temp_zinit.start_dmap = (word)tempbyte;
20317 5 }
20318 else
20319 {
20320
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20321 {
20322 return qe_invalid;
20323 }
20324 }
20325
20326
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20327 {
20328 return qe_invalid;
20329 }
20330 110 }
20331
20332
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
110 if(s_version>1 && s_version < 29)
20333 {
20334
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20335 return qe_invalid;
20336 76 temp_zinit.arrows = padding;
20337
20338
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20339 return qe_invalid;
20340 76 temp_zinit.max_arrows = padding;
20341 76 }
20342
20343
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version>2)
20344 {
20345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version <= 10)
20346 {
20347 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20348 {
20349 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20350 {
20351 return qe_invalid;
20352 }
20353 }
20354 }
20355 else
20356 {
20357
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXLEVELS; i++)
20358 {
20359
2/4
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✗ Branch 3 not taken.
53760 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20360 {
20361 return qe_invalid;
20362 }
20363 53760 }
20364 }
20365 105 }
20366
20367
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>3)
20368 {
20369
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20370 {
20371 return qe_invalid;
20372 }
20373
20374
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20375 {
20376 return qe_invalid;
20377 }
20378
20379
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20380 {
20381 return qe_invalid;
20382 }
20383
20384
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20385 {
20386 return qe_invalid;
20387 }
20388
20389
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20390 {
20391 return qe_invalid;
20392 }
20393
20394
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20395 {
20396 return qe_invalid;
20397 }
20398
20399
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20400 {
20401 return qe_invalid;
20402 }
20403
20404
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20405 {
20406 return qe_invalid;
20407 }
20408
20409
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20410
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20411 105 }
20412
20413
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>4 && s_version<15)
20414 {
20415 if(!p_getc(&moving_fairy_hearts,f,true))
20416 {
20417 return qe_invalid;
20418 }
20419
20420 if(!p_getc(&moving_fairy_heart_percent,f,true))
20421 {
20422 return qe_invalid;
20423 }
20424 }
20425
20426
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>5 && s_version < 10)
20427 {
20428 if(!p_getc(&temp,f,true))
20429 {
20430 return qe_invalid;
20431 }
20432
20433 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20434 }
20435
20436
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>6 && s_version<15)
20437 {
20438 if(!p_getc(&stationary_fairy_hearts,f,true))
20439 {
20440 return qe_invalid;
20441 }
20442
20443 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20444 {
20445 return qe_invalid;
20446 }
20447
20448 if(!p_getc(&moving_fairy_magic,f,true))
20449 {
20450 return qe_invalid;
20451 }
20452
20453 if(!p_getc(&moving_fairy_magic_percent,f,true))
20454 {
20455 return qe_invalid;
20456 }
20457
20458 if(!p_getc(&stationary_fairy_magic,f,true))
20459 {
20460 return qe_invalid;
20461 }
20462
20463 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20464 {
20465 return qe_invalid;
20466 }
20467
20468 if(!p_getc(&blue_potion_hearts,f,true))
20469 {
20470 return qe_invalid;
20471 }
20472
20473 if(!p_getc(&blue_potion_heart_percent,f,true))
20474 {
20475 return qe_invalid;
20476 }
20477
20478 if(!p_getc(&red_potion_hearts,f,true))
20479 {
20480 return qe_invalid;
20481 }
20482
20483 if(!p_getc(&red_potion_heart_percent,f,true))
20484 {
20485 return qe_invalid;
20486 }
20487
20488 if(!p_getc(&blue_potion_magic,f,true))
20489 {
20490 return qe_invalid;
20491 }
20492
20493 if(!p_getc(&blue_potion_magic_percent,f,true))
20494 {
20495 return qe_invalid;
20496 }
20497
20498 if(!p_getc(&red_potion_magic,f,true))
20499 {
20500 return qe_invalid;
20501 }
20502
20503 if(!p_getc(&red_potion_magic_percent,f,true))
20504 {
20505 return qe_invalid;
20506 }
20507 }
20508
20509
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>6)
20510 {
20511
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20512 {
20513 return qe_invalid;
20514 }
20515 105 }
20516
20517
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>7)
20518 {
20519
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20520 {
20521 return qe_invalid;
20522 }
20523 105 }
20524
20525
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>8)
20526 {
20527
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20528 {
20529 return qe_invalid;
20530 }
20531
20532
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_keys,f,true))
20533 {
20534 return qe_invalid;
20535 }
20536 105 }
20537
20538
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>16)
20539 {
20540
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.gravity,f,true))
20541 {
20542 return qe_invalid;
20543 }
20544
20545
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.terminalv,f,true))
20546 {
20547 return qe_invalid;
20548 }
20549
20550
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_speed,f,true))
20551 {
20552 return qe_invalid;
20553 }
20554
20555
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.transition_type,f,true))
20556 {
20557 return qe_invalid;
20558 }
20559
20560
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20561 {
20562 return qe_invalid;
20563 }
20564 105 }
20565
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20566 5 temp_zinit.msg_speed = 0;
20567
20568
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>17)
20569 {
20570
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20571 {
20572 return qe_invalid;
20573 }
20574 105 }
20575
20576 //expaned init data for larger values in 2.55
20577
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20578 {
20579
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.bombs,f,true))
20580 {
20581 return qe_invalid;
20582 }
20583
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20584 {
20585 return qe_invalid;
20586 }
20587
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20588 {
20589 return qe_invalid;
20590 }
20591
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20592 {
20593 return qe_invalid;
20594 }
20595
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.arrows,f,true))
20596 {
20597 return qe_invalid;
20598 }
20599
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20600 {
20601 return qe_invalid;
20602 }
20603
20604 29 }
20605
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 20 )
20606 {
20607
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroStep,f,true))
20608 {
20609 return qe_invalid;
20610 }
20611 29 }
20612 else
20613 {
20614 81 temp_zinit.heroStep = 150; //1.5 pixels per frame
20615 }
20616
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 21 )
20617 {
20618
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20619 {
20620 return qe_invalid;
20621 }
20622 29 }
20623 else
20624 {
20625 81 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20626 }
20627 //old only
20628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version == 0x192)&&(Header->build<174))
20629 {
20630 byte items2;
20631
20632 if(!p_getc(&items2,f,true))
20633 {
20634 return qe_invalid;
20635 }
20636
20637 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20638 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20639 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20640 }
20641
20642
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
20643 {
20644 for(int32_t q=0; q<96; q++)
20645 {
20646 if(!p_getc(&padding,f,true))
20647 {
20648 return qe_invalid;
20649 }
20650 }
20651
20652 //new only
20653 if((Header->zelda_version == 0x192)&&(Header->build>173))
20654 {
20655 if(!p_getc(&padding,f,true))
20656 {
20657 return qe_invalid;
20658 }
20659
20660 if(!p_getc(&padding,f,true))
20661 {
20662 return qe_invalid;
20663 }
20664 }
20665 }
20666 110 }
20667
20668
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
168 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20669 {
20670 //temp_zinit.shield=i_smallshield;
20671
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 54 times.
63 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20672
20673
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20674 9 temp_zinit.items[sshieldid] = true;
20675 9 }
20676
20677
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20678 {
20679 4 temp_zinit.hc=3;
20680 4 temp_zinit.start_heart=3;
20681 4 temp_zinit.cont_heart=3;
20682 4 temp_zinit.max_bombs=8;
20683 4 }
20684
20685
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20686 {
20687 4 sword_hearts[0]=0;
20688 4 sword_hearts[1]=5;
20689 4 sword_hearts[2]=12;
20690 4 sword_hearts[3]=21;
20691 4 }
20692
20693
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20694 {
20695 4 temp_zinit.last_map=0;
20696 4 temp_zinit.last_screen=0;
20697 4 }
20698
20699
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20700 {
20701 4 temp_zinit.max_magic=0;
20702 4 temp_zinit.magic=0;
20703
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20704 4 }
20705
20706
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20707 {
20708
20709
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20710 {
20711 16 beam_hearts[x]=100;
20712 16 }
20713
20714
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20715 {
20716
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20717
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20718 16 }
20719
20720
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20721 {
20722
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20723 16 }
20724
20725
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20726 4 hookshot_links=100;
20727 4 temp_zinit.msg_more_x=224;
20728 4 temp_zinit.msg_more_y=64;
20729 4 }
20730
20731 // Okay, let's put these legacy values into itemsbuf.
20732
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 15)
20733
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20734 {
20735
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20736 {
20737 case iFairyStill:
20738 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20739 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20740 9 itemsbuf[i].misc3 = 0;
20741 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20742 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20743 9 break;
20744
20745 case iFairyMoving:
20746 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20747 9 itemsbuf[i].misc2 = moving_fairy_magic;
20748 9 itemsbuf[i].misc3 = 50;
20749 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20750 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20751 9 break;
20752
20753 case iRPotion:
20754 9 itemsbuf[i].misc1 = red_potion_hearts;
20755 9 itemsbuf[i].misc2 = red_potion_magic;
20756 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20757 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20758 9 break;
20759
20760 case iBPotion:
20761 9 itemsbuf[i].misc1 = blue_potion_hearts;
20762 9 itemsbuf[i].misc2 = blue_potion_magic;
20763 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20764 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20765 9 break;
20766
20767 case iSword:
20768 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20769 9 itemsbuf[i].misc1 = beam_hearts[0];
20770 9 itemsbuf[i].misc2 = beam_power[0];
20771 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20772
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20773 9 break;
20774
20775 case iWSword:
20776 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20777 9 itemsbuf[i].misc1 = beam_hearts[1];
20778 9 itemsbuf[i].misc2 = beam_power[1];
20779
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20780 9 break;
20781
20782 case iMSword:
20783 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20784 9 itemsbuf[i].misc1 = beam_hearts[2];
20785 9 itemsbuf[i].misc2 = beam_power[2];
20786
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20787 9 break;
20788
20789 case iXSword:
20790 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20791 9 itemsbuf[i].misc1 = beam_hearts[3];
20792 9 itemsbuf[i].misc2 = beam_power[3];
20793
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20794 9 break;
20795
20796 case iHookshot:
20797 9 itemsbuf[i].misc1 = hookshot_length;
20798 9 itemsbuf[i].misc2 = hookshot_links;
20799 9 break;
20800
20801 case iLongshot:
20802 9 itemsbuf[i].misc1 = longshot_length;
20803 9 itemsbuf[i].misc2 = longshot_links;
20804 9 break;
20805 }
20806 2313 }
20807
20808
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20809 {
20810 //was new subscreen rule
20811
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20812
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20813 4 }
20814
20815
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20816 {
20817 4 temp_zinit.start_dmap=0;
20818 4 }
20819
20820
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20821 {
20822
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20823 4 }
20824
20825
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
114 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20826 {
20827 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20828 temp_zinit.max_rupees=999;
20829 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20830 }
20831
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20832 {
20833 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20834 temp_zinit.max_bombs = 8;
20835 }
20836 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20837 //time to ensure that we port all new values properly:
20838
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(Header->zelda_version < 0x250)
20839 {
20840
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20841 9 }
20842
20843
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 21)
20844 {
20845
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20846 {
20847 return qe_invalid;
20848 }
20849
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20850 {
20851 return qe_invalid;
20852 }
20853
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20854 {
20855 return qe_invalid;
20856 }
20857
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20858 {
20859 return qe_invalid;
20860 }
20861 29 }
20862 else
20863 {
20864 85 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20865 85 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20866 85 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20867 85 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20868 }
20869
20870
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 22)
20871 {
20872
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 29 times.
754 for(int32_t q = 0; q < 25; ++q)
20873 {
20874
2/4
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 725 times.
725 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20875 {
20876 return qe_invalid;
20877 }
20878 725 }
20879
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 29 times.
754 for(int32_t q = 0; q < 25; ++q)
20880 {
20881
2/4
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 725 times.
725 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20882 {
20883 return qe_invalid;
20884 }
20885 725 }
20886 29 }
20887 else
20888 {
20889
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 85 times.
2210 for(int32_t q = 0; q < 25; ++q)
20890 {
20891 2125 temp_zinit.scrcnt[q] = 0;
20892 2125 temp_zinit.scrmaxcnt[q] = 0;
20893 2125 }
20894 }
20895
20896
20897
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 23)
20898 {
20899
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_type,f,true))
20900 {
20901 return qe_invalid;
20902 }
20903
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_arg,f,true))
20904 {
20905 return qe_invalid;
20906 }
20907
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_percent,f,true))
20908 {
20909 return qe_invalid;
20910 }
20911
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20912 {
20913 return qe_invalid;
20914 }
20915
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20916 {
20917 return qe_invalid;
20918 }
20919 29 }
20920 else
20921 {
20922 85 temp_zinit.dither_type = 0;
20923 85 temp_zinit.dither_arg = 0;
20924 85 temp_zinit.dither_percent = 20;
20925 85 temp_zinit.def_lightrad = 24;
20926 85 temp_zinit.transdark_percent = 0;
20927 }
20928
20929
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 24)
20930 {
20931
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.darkcol,f,true))
20932 {
20933 return qe_invalid;
20934 }
20935 29 }
20936 else
20937 {
20938 85 temp_zinit.darkcol = BLACK;
20939 }
20940
20941
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 25)
20942 {
20943
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.gravity2,f,true))
20944 {
20945 return qe_invalid;
20946 }
20947
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20948 {
20949 return qe_invalid;
20950 }
20951 29 }
20952 else
20953 {
20954 85 temp_zinit.gravity2 = temp_zinit.gravity*100;
20955 85 temp_zinit.swimgravity = 5;
20956 }
20957
20958
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 26)
20959 {
20960
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20961 {
20962 return qe_invalid;
20963 }
20964
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20965 {
20966 return qe_invalid;
20967 }
20968
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20969 {
20970 return qe_invalid;
20971 }
20972 29 }
20973 else
20974 {
20975 85 temp_zinit.heroSideswimUpStep = 150;
20976 85 temp_zinit.heroSideswimSideStep = 100;
20977 85 temp_zinit.heroSideswimDownStep = 75;
20978 }
20979
20980
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 27)
20981 {
20982
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20983 {
20984 return qe_invalid;
20985 }
20986 29 }
20987 else
20988 {
20989 85 temp_zinit.exitWaterJump = 0;
20990 }
20991
20992
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 29)
20993 {
20994
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20995 {
20996 return qe_invalid;
20997 }
20998 29 }
20999 else
21000 {
21001 85 temp_zinit.bunny_ltm = 0;
21002 }
21003
21004
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 30)
21005 {
21006
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
21007 {
21008 return qe_invalid;
21009 }
21010 29 }
21011 else
21012 {
21013 85 temp_zinit.switchhookstyle = 1;
21014 }
21015
21016
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 31)
21017 {
21018
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21019 {
21020 return qe_invalid;
21021 }
21022 29 }
21023 else
21024 {
21025
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21026
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21027 }
21028
21029
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 temp_zinit.clear_genscript();
21030
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(s_version > 32)
21031 {
21032 27 word numgenscript = 0;
21033
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
27 if(!p_igetw(&numgenscript,f,true))
21034 return qe_invalid;
21035
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(auto q = 1; q < numgenscript; ++q)
21036 {
21037 if(!p_getc(&padding,f,true))
21038 return qe_invalid;
21039 if(!(padding&2))
21040 continue;
21041 temp_zinit.gen_doscript[q] = padding&1;
21042 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21043 return qe_invalid;
21044 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21045 return qe_invalid;
21046 for(auto p = 0; p < 8; ++p)
21047 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21048 return qe_invalid;
21049 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21050 return qe_invalid;
21051 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21052 return qe_invalid;
21053 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21054 return qe_invalid;
21055 }
21056 27 }
21057
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(s_version > 33)
21058 {
21059
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21060 return qe_invalid;
21061
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21062 return qe_invalid;
21063 23 }
21064
21065
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(keepdata==true)
21066 {
21067
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zinit = temp_zinit;
21068
21069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(zinit.heroAnimationStyle==las_zelda3slow)
21070 {
21071 hero_animation_speed=2;
21072 }
21073 else
21074 {
21075 114 hero_animation_speed=1;
21076 }
21077 114 }
21078
21079 114 return 0;
21080 442 }
21081
21082 /*
21083 void setupitemdropsets()
21084 {
21085 for(int32_t i=0; i<isMAX; i++)
21086 {
21087 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21088 }
21089 }
21090 */
21091
21092 109 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21093 {
21094 109 build=build; // here to prevent compiler warnings
21095 dword dummy_dword;
21096 109 word item_drop_sets_to_read=0;
21097 item_drop_object tempitemdrop;
21098 109 word s_version=0, s_cversion=0;
21099
21100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
21101 {
21102
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21103 {
21104 27904 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21105 27904 }
21106 109 }
21107
21108
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(version > 0x192)
21109 {
21110 105 item_drop_sets_to_read=0;
21111
21112 //section version info
21113
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
21114 {
21115 return qe_invalid;
21116 }
21117
21118 105 FFCore.quest_format[vItemDropsets] = s_version;
21119
21120 //al_trace("Item drop sets version %d\n", s_version);
21121
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
21122 {
21123 return qe_invalid;
21124 }
21125
21126 //section size
21127
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy_dword,f,true))
21128 {
21129 return qe_invalid;
21130 }
21131
21132 //finally... section data
21133
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&item_drop_sets_to_read,f,true))
21134 {
21135 return qe_invalid;
21136 }
21137 105 }
21138 else
21139 {
21140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21141 {
21142 4 init_item_drop_sets();
21143 4 }
21144 }
21145
21146
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(s_version>=1)
21147 {
21148
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 105 times.
2070 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21149 {
21150
1/2
✓ Branch 0 taken 1965 times.
✗ Branch 1 not taken.
1965 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21151 {
21152 return qe_invalid;
21153 }
21154
21155
2/2
✓ Branch 0 taken 19650 times.
✓ Branch 1 taken 1965 times.
21615 for(int32_t j=0; j<10; ++j)
21156 {
21157
1/2
✓ Branch 0 taken 19650 times.
✗ Branch 1 not taken.
19650 if(!p_igetw(&tempitemdrop.item[j],f,true))
21158 {
21159 return qe_invalid;
21160 }
21161 19650 }
21162
21163
2/2
✓ Branch 0 taken 21615 times.
✓ Branch 1 taken 1965 times.
23580 for(int32_t j=0; j<11; ++j)
21164 {
21165
1/2
✓ Branch 0 taken 21615 times.
✗ Branch 1 not taken.
21615 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21166 {
21167 return qe_invalid;
21168 }
21169 21615 }
21170
21171 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21172 // overrides the quest's set #12.
21173
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1965 if(s_version<2 && i==12)
21174 continue;
21175
21176 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21177
1/4
✓ Branch 0 taken 1965 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1965 if(s_version<2) for(int32_t j=0; j<10; ++j)
21178 {
21179 int32_t it = tempitemdrop.item[j];
21180
21181 if((itemsbuf[it].family == itype_rupee
21182 && ((itemsbuf[it].amount)&0xFFF) == 10)
21183 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21184 {
21185 tempitemdrop.chance[j+1]=0;
21186 }
21187 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21188 {
21189 tempitemdrop.chance[j+1]=0;
21190 }
21191
21192 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21193 if(itemsbuf[it].family == itype_misc)
21194 {
21195 // If a non-gameplay item was selected, then item drop was aborted.
21196 // Reflect this by increasing the 'Nothing' chance accordingly.
21197 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21198 tempitemdrop.chance[j+1]=0;
21199 }
21200 }
21201
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(keepdata)
21203 {
21204 1965 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21205 1965 }
21206 1965 }
21207 105 }
21208
21209 109 return 0;
21210 109 }
21211
21212 105 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21213 {
21214 int32_t temp_num;
21215 dword dummy_dword;
21216 word num_favorite_combos;
21217 word num_favorite_combo_aliases;
21218 105 word s_version=0, s_cversion=0;
21219
21220 //section version info
21221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
21222 {
21223 return qe_invalid;
21224 }
21225
21226 105 FFCore.quest_format[vFavourites] = s_version;
21227
21228
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
21229 {
21230 return qe_invalid;
21231 }
21232
21233 //section size
21234
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy_dword,f,true))
21235 {
21236 return qe_invalid;
21237 }
21238
21239 105 word per_row = FAVORITECOMBO_PER_ROW;
21240
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 23 times.
105 if(s_version >= 3)
21241
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&per_row,f,true))
21242 return qe_invalid;
21243 //finally... section data
21244
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&num_favorite_combos,f,true))
21245 {
21246 return qe_invalid;
21247 }
21248
21249 //Hack; port old favorite combos
21250
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
105 if(s_version < 3 && num_favorite_combos == 100)
21251 82 per_row = 13;
21252
21253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
21254 {
21255
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21256 31500 favorite_combos[q] = -1;
21257
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21258 31500 favorite_comboaliases[q] = -1;
21259 105 }
21260
2/2
✓ Branch 0 taken 8727 times.
✓ Branch 1 taken 105 times.
8832 for(int32_t i=0; i<num_favorite_combos; i++)
21261 {
21262
1/2
✓ Branch 0 taken 8727 times.
✗ Branch 1 not taken.
8727 if(!p_igetl(&temp_num,f,true))
21263 {
21264 return qe_invalid;
21265 }
21266
21267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8727 times.
8727 if(keepdata)
21268 {
21269
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 8200 times.
8727 if(per_row == FAVORITECOMBO_PER_ROW)
21270 527 favorite_combos[i]=temp_num;
21271 else
21272 {
21273 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21274 8200 favorite_combos[new_i]=temp_num;
21275 }
21276 8727 }
21277 8727 }
21278
21279
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21280 {
21281 return qe_invalid;
21282 }
21283
21284
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 105 times.
8305 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21285 {
21286
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if(!p_igetl(&temp_num,f,true))
21287 {
21288 return qe_invalid;
21289 }
21290
21291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(keepdata)
21292 {
21293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(per_row == FAVORITECOMBO_PER_ROW)
21294 favorite_comboaliases[i]=temp_num;
21295 else
21296 {
21297 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21298 8200 favorite_comboaliases[new_i]=temp_num;
21299 }
21300 8200 }
21301 8200 }
21302
21303 105 word max_combo_cols = 0;
21304 105 word max_mappages = 0;
21305
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 23 times.
105 if(s_version >= 2)
21306 {
21307
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&max_combo_cols,f,true))
21308 return qe_invalid;
21309 23 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21310
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int q = 0; q < max_combo_cols; ++q)
21311 {
21312
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tmp,f,true))
21313 return qe_invalid;
21314
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tmp2,f,true))
21315 return qe_invalid;
21316
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tmp3,f,true))
21317 return qe_invalid;
21318
2/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
92 if(keepdata && q < MAX_COMBO_COLS)
21319 {
21320 92 First[q] = tmp;
21321 92 combo_alistpos[q] = tmp2;
21322 92 combo_pool_listpos[q] = tmp3;
21323 92 }
21324 92 }
21325
21326
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&max_mappages,f,true))
21327 return qe_invalid;
21328
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 23 times.
230 for(int q = 0; q < max_mappages; ++q)
21329 {
21330
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetl(&tmp,f,true))
21331 return qe_invalid;
21332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 if(!p_igetl(&tmp2,f,true))
21333 return qe_invalid;
21334
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 207 times.
207 if(keepdata && q < MAX_MAPPAGE_BTNS)
21335 {
21336 207 map_page[q].map = tmp;
21337 207 map_page[q].screen = tmp2;
21338 207 }
21339 207 }
21340 23 }
21341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
21342 {
21343
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 105 times.
433 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21344 {
21345 328 First[q] = 0;
21346 328 combo_alistpos[q] = 0;
21347 328 combo_pool_listpos[q] = 0;
21348 328 }
21349
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 105 times.
843 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21350 {
21351 738 map_page[q].map = 0;
21352 738 map_page[q].screen = 0;
21353 738 }
21354 105 }
21355
21356 105 return 0;
21357 105 }
21358
21359 /*
21360 switch (ret) {
21361 case 0:
21362 break;
21363
21364 case qe_invalid:
21365 goto invalid;
21366 break;
21367 default:
21368 pack_fclose(f);
21369 if(!oldquest)
21370 delete_file(tmpfilename);
21371 return ret;
21372 break;
21373 }
21374 */
21375
21376 const char *skip_text[skip_max]=
21377 {
21378 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21379 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21380 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21381 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21382 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21383 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21384 "skip_favorites"
21385 };
21386
21387
21388 void port250QuestRules(){
21389
21390 portCandleRules(); //Candle
21391 portBombRules();
21392
21393 }
21394
21395 void portCandleRules()
21396 {
21397 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21398 //itemdata itemsbuf;
21399 for ( int32_t q = 0; q < MAXITEMS; q++ )
21400 {
21401 if ( itemsbuf[q].family == itype_candle )
21402 {
21403 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21404 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21405 }
21406 }
21407 }
21408
21409 void portBombRules()
21410 {
21411 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21412 //itemdata itemsbuf;
21413 for ( int32_t q = 0; q < MAXITEMS; q++ )
21414 {
21415 if ( itemsbuf[q].family == itype_bomb )
21416 {
21417 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21418 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21419 }
21420 }
21421
21422 }
21423
21424 //Internal function for loadquest wrapper
21425 114 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21426 {
21427 114 DMapEditorLastMaptileUsed = 0;
21428 114 combosread=false;
21429 114 mapsread=false;
21430 114 fixffcs=false;
21431
21432
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21433 {
21434 keepall=false;
21435 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21436 }
21437
21438 // show_progress=true;
21439 char tmpfilename[L_tmpnam];
21440 114 temp_name(tmpfilename);
21441 // char percent_done[30];
21442 114 bool catchup=false;
21443 byte tempbyte;
21444 114 word old_map_count=map_count;
21445
21446 114 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21447 114 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21448 114 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21449
21450
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall==false||get_bit(skip_flags, skip_rules))
21451 {
21452 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21453 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21454 }
21455
21456 114 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21457 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21458
21459
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall==false||get_bit(skip_flags, skip_midis))
21460 {
21461 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21462 }
21463
21464
21465
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21466 {
21467 114 zScript.clear();
21468 114 globalmap.clear();
21469 114 genericmap.clear();
21470 114 ffcmap.clear();
21471 114 itemmap.clear();
21472 114 npcmap.clear();
21473 114 ewpnmap.clear();
21474 114 lwpnmap.clear();
21475 114 playermap.clear();
21476 114 dmapmap.clear();
21477 114 screenmap.clear();
21478 114 itemspritemap.clear();
21479 114 comboscriptmap.clear();
21480
21481
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21482 {
21483 58254 ffcmap[i].clear();
21484 58254 }
21485
21486 114 globalmap[0].slotname = "Slot 1:";
21487 114 globalmap[0].scriptname = "~Init";
21488 114 globalmap[0].update();
21489
21490
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 114 times.
912 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21491 {
21492 798 globalmap[i].clear();
21493 798 }
21494
21495
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21496 {
21497 29070 itemmap[i].clear();
21498 29070 }
21499
21500 //new script types -- prevent carrying over to a quest that you load after reading them
21501 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21502
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21503 {
21504 29070 npcmap[i].clear();
21505 29070 }
21506
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21507 {
21508 29070 lwpnmap[i].clear();
21509 29070 }
21510
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21511 {
21512 29070 ewpnmap[i].clear();
21513 29070 }
21514
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 114 times.
570 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21515 {
21516 456 playermap[i].clear();
21517 456 }
21518
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21519 {
21520 29070 dmapmap[i].clear();
21521 29070 }
21522
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21523 {
21524 29070 screenmap[i].clear();
21525 29070 }
21526
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21527 {
21528 29070 itemspritemap[i].clear();
21529 29070 }
21530
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21531 {
21532 58254 comboscriptmap[i].clear();
21533 58254 }
21534
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21535 {
21536 58254 genericmap[i].clear();
21537 58254 }
21538
21539 114 reset_scripts();
21540 114 }
21541
21542 zquestheader tempheader;
21543 114 memset(&tempheader, 0, sizeof(zquestheader));
21544 114 zinfo tempzi;
21545 114 tempzi.clear();
21546 114 load_tmp_zi = &tempzi;
21547
21548 // oldquest flag is set when an unencrypted qst file is suspected.
21549 114 bool oldquest = false;
21550 114 int32_t open_error=0;
21551 114 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21552
21553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!f)
21554 {
21555 ASSERT(open_error != 0);
21556 return open_error;
21557 }
21558 char zinfofilename[2048];
21559 114 replace_extension(zinfofilename, filename, "zinfo", 2047);
21560 114 int32_t ret=0;
21561
21562 //header
21563 114 box_out("Reading Header...");
21564 114 ret=readheader(f, &tempheader, true, printmetadata);
21565
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
114 checkstatus(ret);
21566 114 box_out("okay.");
21567 114 box_eol();
21568
21569
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(read_zinfo)
21570 {
21571 29 box_out("Reading ZInfo - ");
21572
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28 times.
29 box_out(read_ext_zinfo ? "External..." : "Internal...");
21573
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28 times.
29 if(read_ext_zinfo)
21574 {
21575 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21576 1 ret=readzinfo(inf, tempzi, tempheader);
21577
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21578
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21579 1 }
21580 else
21581 {
21582 28 ret=readzinfo(f, tempzi, tempheader);
21583
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
28 checkstatus(ret);
21584 }
21585 29 box_out("okay.");
21586 29 box_eol();
21587 29 }
21588
21589
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(tempheader.zelda_version>=0x193)
21590 {
21591 dword section_id;
21592
21593 //section id
21594
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_mgetl(&section_id,f,true))
21595 {
21596 return qe_invalid;
21597 }
21598
21599
2/2
✓ Branch 0 taken 2595 times.
✓ Branch 1 taken 110 times.
2705 while(!pack_feof(f))
21600 {
21601
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 110 times.
✓ Branch 6 taken 105 times.
✓ Branch 7 taken 110 times.
✓ Branch 8 taken 110 times.
✓ Branch 9 taken 110 times.
✓ Branch 10 taken 110 times.
✓ Branch 11 taken 110 times.
✓ Branch 12 taken 110 times.
✓ Branch 13 taken 105 times.
✓ Branch 14 taken 105 times.
✓ Branch 15 taken 110 times.
✓ Branch 16 taken 110 times.
✓ Branch 17 taken 105 times.
✓ Branch 18 taken 105 times.
✓ Branch 19 taken 105 times.
✓ Branch 20 taken 105 times.
✓ Branch 21 taken 110 times.
✓ Branch 22 taken 110 times.
✓ Branch 23 taken 105 times.
✓ Branch 24 taken 105 times.
2595 switch(section_id)
21602 {
21603 case ID_RULES:
21604
21605 //rules
21606
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21607 {
21608 box_out("found.");
21609 box_eol();
21610 catchup=false;
21611 }
21612
21613 110 box_out("Reading Rules...");
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21615
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21616 110 box_out("okay.");
21617 110 box_eol();
21618 110 break;
21619
21620 case ID_STRINGS:
21621
21622 //strings
21623
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21624 {
21625 box_out("found.");
21626 box_eol();
21627 catchup=false;
21628 }
21629
21630 110 box_out("Reading Strings...");
21631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21632
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21633 110 box_out("okay.");
21634 110 box_eol();
21635 110 break;
21636
21637 case ID_MISC:
21638
21639 //misc data
21640
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21641 {
21642 box_out("found.");
21643 box_eol();
21644 catchup=false;
21645 }
21646
21647 110 box_out("Reading Misc. Data...");
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21649
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21650 110 box_out("okay.");
21651 110 box_eol();
21652 110 break;
21653
21654 case ID_TILES:
21655
21656 //tiles
21657
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21658 {
21659 box_out("found.");
21660 box_eol();
21661 catchup=false;
21662 }
21663
21664 110 box_out("Reading Tiles...");
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21666
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21667 110 box_out("okay.");
21668 110 box_eol();
21669 110 break;
21670
21671 case ID_COMBOS:
21672
21673 //combos
21674
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21675 {
21676 box_out("found.");
21677 box_eol();
21678 catchup=false;
21679 }
21680
21681 110 box_out("Reading Combos...");
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21683 110 combosread=true;
21684
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21685 110 box_out("okay.");
21686 110 box_eol();
21687 110 break;
21688
21689 case ID_COMBOALIASES:
21690
21691 //combo aliases
21692
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21693 {
21694 box_out("found.");
21695 box_eol();
21696 catchup=false;
21697 }
21698
21699 105 box_out("Reading Combo Aliases...");
21700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21701
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21702 105 box_out("okay.");
21703 105 box_eol();
21704 105 break;
21705
21706 case ID_CSETS:
21707
21708 //color data
21709
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21710 {
21711 box_out("found.");
21712 box_eol();
21713 catchup=false;
21714 }
21715
21716 110 box_out("Reading Color Data...");
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21718
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21719 110 box_out("okay.");
21720 110 box_eol();
21721 110 break;
21722
21723 case ID_MAPS:
21724
21725 //maps
21726
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21727 {
21728 box_out("found.");
21729 box_eol();
21730 catchup=false;
21731 }
21732
21733 110 box_out("Reading Maps...");
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21735 110 mapsread=true;
21736
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21737 110 box_out("okay.");
21738 110 box_eol();
21739 110 break;
21740
21741 case ID_DMAPS:
21742
21743 //dmaps
21744
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21745 {
21746 box_out("found.");
21747 box_eol();
21748 catchup=false;
21749 }
21750
21751 110 box_out("Reading DMaps...");
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21753
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21754 110 box_out("okay.");
21755 110 box_eol();
21756 110 break;
21757
21758 case ID_DOORS:
21759
21760 //door combo sets
21761
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21762 {
21763 box_out("found.");
21764 box_eol();
21765 catchup=false;
21766 }
21767
21768 110 box_out("Reading Doors...");
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21770
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21771 110 box_out("okay.");
21772 110 box_eol();
21773 110 break;
21774
21775 case ID_ITEMS:
21776
21777 //items
21778
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21779 {
21780 box_out("found.");
21781 box_eol();
21782 catchup=false;
21783 }
21784
21785 110 box_out("Reading Items...");
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21787
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21788
21789 110 box_out("okay.");
21790 110 box_eol();
21791 110 break;
21792
21793 case ID_WEAPONS:
21794
21795 //weapons
21796
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21797 {
21798 box_out("found.");
21799 box_eol();
21800 catchup=false;
21801 }
21802
21803 110 box_out("Reading Weapons...");
21804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21805
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21806 110 box_out("okay.");
21807 110 box_eol();
21808 110 break;
21809
21810 case ID_COLORS:
21811
21812 //misc. colors
21813
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21814 {
21815 box_out("found.");
21816 box_eol();
21817 catchup=false;
21818 }
21819
21820 105 box_out("Reading Misc. Colors...");
21821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21822
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21823 105 box_out("okay.");
21824 105 box_eol();
21825 105 break;
21826
21827 case ID_ICONS:
21828
21829 //game icons
21830
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21831 {
21832 box_out("found.");
21833 box_eol();
21834 catchup=false;
21835 }
21836
21837 105 box_out("Reading Game Icons...");
21838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21839
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21840 105 box_out("okay.");
21841 105 box_eol();
21842 105 break;
21843
21844 case ID_INITDATA:
21845
21846 //initialization data
21847
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21848 {
21849 box_out("found.");
21850 box_eol();
21851 catchup=false;
21852 }
21853
21854 110 box_out("Reading Init. Data...");
21855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21856
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21857 110 box_out("okay.");
21858 110 box_eol();
21859
21860
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21861 {
21862
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 19 times.
110 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21863 {
21864 19 setupsubscreens();
21865
21866
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19 times.
9747 for(int32_t i=0; i<MAXDMAPS; ++i)
21867 {
21868 9728 int32_t type=DMaps[i].type&dmfTYPE;
21869
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 9634 times.
9728 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21870 9728 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21871 9728 }
21872 19 }
21873 110 }
21874
21875
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_sfx))
21876 {
21877 110 setupsfx();
21878 110 }
21879
21880
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21881 {
21882 110 init_item_drop_sets();
21883 110 }
21884
21885
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_favorites))
21886 {
21887 110 init_favorites();
21888 110 }
21889
21890 110 break;
21891
21892 case ID_GUYS:
21893
21894 //guys
21895
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21896 {
21897 box_out("found.");
21898 box_eol();
21899 catchup=false;
21900 }
21901
21902 110 box_out("Reading Custom Guy Data...");
21903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21904
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21905 110 box_out("okay.");
21906 110 box_eol();
21907 110 break;
21908
21909 case ID_HEROSPRITES:
21910
21911 //player sprites
21912
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21913 {
21914 box_out("found.");
21915 box_eol();
21916 catchup=false;
21917 }
21918
21919 105 box_out("Reading Custom Player Sprite Data...");
21920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21921
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21922 105 box_out("okay.");
21923 105 box_eol();
21924 105 break;
21925
21926 case ID_SUBSCREEN:
21927
21928 //custom subscreens
21929
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21930 {
21931 box_out("found.");
21932 box_eol();
21933 catchup=false;
21934 }
21935
21936 105 box_out("Reading Custom Subscreen Data...");
21937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21938
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21939 105 box_out("okay.");
21940 105 box_eol();
21941 105 break;
21942
21943 case ID_FFSCRIPT:
21944
21945 //Freeform combo scripts
21946
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21947 {
21948 box_out("found.");
21949 box_eol();
21950 catchup=false;
21951 }
21952
21953 105 box_out("Reading FF Script Data...");
21954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21955
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21956 105 box_out("okay.");
21957 105 box_eol();
21958 105 break;
21959
21960 case ID_SFX:
21961
21962 //SFX data
21963
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21964 {
21965 box_out("found.");
21966 box_eol();
21967 catchup=false;
21968 }
21969
21970 105 box_out("Reading SFX Data...");
21971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21972
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21973 105 box_out("okay.");
21974 105 box_eol();
21975 105 break;
21976
21977 case ID_MIDIS:
21978
21979 //midis
21980
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21981 {
21982 box_out("found.");
21983 box_eol();
21984 catchup=false;
21985 }
21986
21987 110 box_out("Reading Tunes...");
21988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21989
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21990 110 box_out("okay.");
21991 110 box_eol();
21992 110 break;
21993
21994 case ID_CHEATS:
21995
21996 //cheat codes
21997
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21998 {
21999 box_out("found.");
22000 box_eol();
22001 catchup=false;
22002 }
22003
22004 110 box_out("Reading Cheat Codes...");
22005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22006
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
22007 110 box_out("okay.");
22008 110 box_eol();
22009 110 break;
22010
22011 case ID_ITEMDROPSETS:
22012
22013 //item drop sets
22014
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
22015 {
22016 box_out("found.");
22017 box_eol();
22018 catchup=false;
22019 }
22020
22021 105 box_out("Reading Item Drop Sets...");
22022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22023
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
22024 105 box_out("okay.");
22025 105 box_eol();
22026 105 break;
22027
22028 case ID_FAVORITES:
22029
22030 //favorite combos and combo aliases
22031
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
22032 {
22033 box_out("found.");
22034 box_eol();
22035 catchup=false;
22036 }
22037
22038 105 box_out("Reading Favorite Combos...");
22039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
22040
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
22041 105 box_out("okay.");
22042 105 box_eol();
22043 105 break;
22044
22045 default:
22046 if(!catchup)
22047 {
22048 box_out("Bad token! Searching...");
22049 box_eol();
22050 }
22051
22052 catchup=true;
22053 break;
22054 }
22055
22056
22057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2595 times.
2595 if(catchup)
22058 {
22059 //section id
22060 section_id=(section_id<<8);
22061
22062 if(!p_getc(&tempbyte,f,true))
22063 {
22064 return qe_invalid;
22065 }
22066
22067 section_id+=tempbyte;
22068 }
22069
22070 else
22071 {
22072 //section id
22073
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 2485 times.
2595 if(!pack_feof(f))
22074 {
22075
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if(!p_mgetl(&section_id,f,true))
22076 {
22077 return qe_invalid;
22078 }
22079 2485 }
22080 }
22081 }
22082 110 }
22083 else
22084 {
22085 //rules
22086 4 box_out("Reading Rules...");
22087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22088
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22089 4 box_out("okay.");
22090 4 box_eol();
22091
22092 //strings
22093 4 box_out("Reading Strings...");
22094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22095
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22096 4 box_out("okay.");
22097 4 box_eol();
22098
22099 //door combo sets
22100 4 box_out("Reading Doors...");
22101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22102
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22103 4 box_out("okay.");
22104 4 box_eol();
22105
22106 //dmaps
22107 4 box_out("Reading DMaps...");
22108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22109
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22110 4 box_out("okay.");
22111 4 box_eol();
22112
22113 // misc data
22114 4 box_out("Reading Misc. Data...");
22115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22116
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22117 4 box_out("okay.");
22118 4 box_eol();
22119
22120 //items
22121 4 box_out("Reading Items...");
22122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22123
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22124 4 box_out("okay.");
22125 4 box_eol();
22126
22127 //weapons
22128 4 box_out("Reading Weapons...");
22129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22130
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22131 4 box_out("okay.");
22132 4 box_eol();
22133
22134 //guys
22135 4 box_out("Reading Custom Guy Data...");
22136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22137
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22138 4 box_out("okay.");
22139 4 box_eol();
22140
22141 //maps
22142 4 box_out("Reading Maps...");
22143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22144 4 mapsread=true;
22145
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22146 4 box_out("okay.");
22147 4 box_eol();
22148
22149 //combos
22150 4 box_out("Reading Combos...");
22151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22152 4 combosread=true;
22153
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22154 4 box_out("okay.");
22155 4 box_eol();
22156
22157 //color data
22158 4 box_out("Reading Color Data...");
22159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22160
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22161 4 box_out("okay.");
22162 4 box_eol();
22163
22164 //tiles
22165 4 box_out("Reading Tiles...");
22166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22167
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22168 4 box_out("okay.");
22169 4 box_eol();
22170
22171 //midis
22172 4 box_out("Reading Tunes...");
22173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22174
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22175 4 box_out("okay.");
22176 4 box_eol();
22177
22178 //cheat codes
22179 4 box_out("Reading Cheat Codes...");
22180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22181
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22182 4 box_out("okay.");
22183 4 box_eol();
22184
22185 //initialization data
22186 4 box_out("Reading Init. Data...");
22187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22188
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22189 4 box_out("okay.");
22190 4 box_eol();
22191
22192
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22193 {
22194 4 setupsubscreens();
22195
22196
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22197 {
22198 2048 int32_t type=DMaps[i].type&dmfTYPE;
22199
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22200 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22201 2048 }
22202 4 }
22203
22204 4 box_out("Setting Up Default Sound Effects...");
22205
22206
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22207 4 setupsfx();
22208
22209 4 box_out("okay.");
22210 4 box_eol();
22211
22212 //player sprites
22213 4 box_out("Reading Custom Player Sprite Data...");
22214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22215
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22216 4 box_out("okay.");
22217 4 box_eol();
22218
22219 4 box_out("Setting Up Default Item Drop Sets...");
22220
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22221 4 box_out("okay.");
22222 4 box_eol();
22223 }
22224
22225 114 init_spritelists();
22226
22227 // check data
22228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(f)
22229 {
22230 114 pack_fclose(f);
22231 114 }
22232 114 clear_quest_tmpfile();
22233
22234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!oldquest)
22235 {
22236
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(exists(tmpfilename))
22237 {
22238 delete_file(tmpfilename);
22239 }
22240 114 }
22241
22242
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(fixffcs && combosread && mapsread)
22243 {
22244 for(int32_t i=0; i<map_count; i++)
22245 {
22246 for(int32_t j=0; j<MAPSCRS; j++)
22247 {
22248 for(int32_t m=0; m<32; m++)
22249 {
22250 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22251 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22252 }
22253 }
22254 }
22255 }
22256
22257
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 22 times.
114 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22258 {
22259 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22260 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22261 22 zinit.cont_heart=100;
22262 22 zinit.start_heart=zinit.hc;
22263 22 }
22264
22265 114 box_out("Done.");
22266 114 box_eol();
22267 114 box_end(false);
22268
22269 // if (keepall==true||!get_bit(skip_flags, skip_header))
22270
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_header))
22271 {
22272 114 memcpy(Header, &tempheader, sizeof(tempheader));
22273 114 }
22274
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22275 {
22276 114 ZI.copyFrom(tempzi);
22277 114 }
22278
22279
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_maps))
22280 {
22281 map_count=old_map_count;
22282 }
22283
22284
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_rules))
22285 {
22286 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22287 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22288 }
22289
22290
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_midis))
22291 {
22292 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22293 }
22294
22295 //Debug FFCore.quest_format[]
22296 114 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22297 114 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22298 114 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22299 114 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22300 114 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22301 114 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22302 114 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22303 114 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22304 114 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22305 114 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22306 114 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22307 114 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22308 114 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22309 114 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22310 114 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22311 114 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22312 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22313 114 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22314 114 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22315 114 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22316 114 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22317 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22318 114 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22319 114 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22320 114 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22321 114 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22322 114 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22323 114 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22324 114 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22325 114 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22326 //Print metadata for versions under 2.10 here. Bleah.
22327
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if( FFCore.quest_format[vZelda] < 0x210 )
22328 {
22329 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22330
22331
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22332 {
22333 case 0x193:
22334 {
22335 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22336 }
22337 case 0x192:
22338 {
22339 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22340 }
22341 case 0x190:
22342 {
22343 4 zprint2("Last saved in ZC Editor Version: 1.90");
22344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22345 4 else zprint2("\n");
22346 4 break;
22347 }
22348 case 0x188:
22349 {
22350 zprint2("Last saved in ZC Editor Version: 1.88");
22351 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22352 else zprint2("\n");
22353 break;
22354 }
22355 case 0x187:
22356 {
22357 zprint2("Last saved in ZC Editor Version: 1.87");
22358 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22359 else zprint2("\n");
22360 break;
22361 }
22362 case 0x186:
22363 {
22364 zprint2("Last saved in ZC Editor Version: 1.86");
22365 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22366 else zprint2("\n");
22367 break;
22368 }
22369 case 0x185:
22370 {
22371 zprint2("Last saved in ZC Editor Version: 1.85");
22372 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22373 else zprint2("\n");
22374 break;
22375 }
22376 case 0x184:
22377 {
22378 zprint2("Last saved in ZC Editor Version: 1.84");
22379 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22380 else zprint2("\n");
22381 break;
22382 }
22383 case 0x183:
22384 {
22385 zprint2("Last saved in ZC Editor Version: 1.83");
22386 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22387 else zprint2("\n");
22388 break;
22389 }
22390 case 0x182:
22391 {
22392 zprint2("Last saved in ZC Editor Version: 1.82");
22393 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22394 else zprint2("\n");
22395 break;
22396 }
22397 case 0x181:
22398 {
22399 zprint2("Last saved in ZC Editor Version: 1.81");
22400 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22401 else zprint2("\n");
22402 break;
22403 }
22404 case 0x180:
22405 {
22406 zprint2("Last saved in ZC Editor Version: 1.80");
22407 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22408 else zprint2("\n");
22409 break;
22410 }
22411 default:
22412 {
22413 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22414 }
22415 }
22416 4 }
22417
22418 114 return qe_OK;
22419
22420 invalid:
22421 box_out("error.");
22422 box_eol();
22423 box_end(true);
22424
22425 if(f)
22426 {
22427 pack_fclose(f);
22428 }
22429
22430 if(!oldquest)
22431 {
22432 if(exists(tmpfilename))
22433 {
22434 delete_file(tmpfilename);
22435 }
22436 }
22437
22438 return qe_invalid;
22439
22440 114 }
22441
22442 114 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22443 {
22444 114 loading_qst_name = filename;
22445 114 loading_qst_num = qst_num;
22446 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22447 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22448
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (!is_ci())
22449 loadquest_report = report;
22450 114 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22451 114 load_tmp_zi = NULL;
22452 114 loading_qst_name = NULL;
22453 114 loadquest_report = false;
22454 114 loading_qst_num = 0;
22455 114 return ret;
22456 }
22457